def _get_leaves(tree, node, totcolcnt):
    return_list = []
    stack = []
    curr = node

    def _walk(node: int, side: int, save=False):
        if (node < totcolcnt):
            if save:
                return_list.append(node)
            return None
        else:
            node = int((node - totcolcnt))
            child = int(tree[node][side])
            return child
    while True:
        if (curr is not None):
            stack.append(curr)
            curr = _walk(curr, LEFT)
        elif stack:
            curr = stack.pop()
            curr = _walk(curr, RIGHT, save=True)
        else:
            break
    return return_list
def _get_leaves(tree, node, totcolcnt):
    return_list = []
    stack = []
    curr = node

    def _walk(node: int, side: int, save=False):
        if (node < totcolcnt):
            if save:
                return_list.append(node)
            return None
        else:
            node = int((node - totcolcnt))
            child = int(tree[node][side])
            return child
    while True:
        if (curr is not None):
            stack.append(curr)
            curr = _walk(curr, LEFT)
        elif stack:
            curr = stack.pop()
            curr = _walk(curr, RIGHT, save=True)
        else:
            break
    return return_list