import math


def _get_depth(node_index):
    """
    The indices in depth d is
        (# of nodes up to depths d - 1) <= indices <= (# of nodes up to depth d) - 1

    where
        (# of nodes up to depth d) = 2^(d + 1) - 1

    :param node_index:
    :return: int for depth
    """
    return int(math.log(node_index + 1, 2))