Compute the next traversal value for a k-d tree given the bounding box and the centroid of the current node, the half number (0 or 1) and the level.