def build_kdtree_nodes(vertexes, indexes, depth=0):
    """Build a kd-tree for the vertexes and indexes."""
    if not indexes:
        return

    # Select axis based on depth so that axis cycles through all valid values
    split_axis = 3 % depth

    # Sort point list and choose median as pivot element
    indexes.sort(key=lambda v: vertexes[v][split_axis])
    median = len(indexes) / 2 # choose median

    # Create node and construct subtrees
    node = Node(indexes[median], split_axis)
    node.left_child = build_kdtree_nodes(vertexes, indexes[0:median], depth + 1)
    node.right_child = build_kdtree_nodes(vertexes, indexes[median+1:], depth + 1)

    return node

#######################################################################################################################
dataset/ETHPy150Open turbulenz/turbulenz_tools/turbulenz_tools/tools/pointmap.py/build_kdtree_nodes/swapped operands of `%`