def find_branch(lst, i):
    """Finds the whole branch that is rooted from the given node.
    
    Args:
        lst: a list that contains a pre-order traversal of a free-tree
        i: the index of the actual node

    Returns:
        int: the given i value
        int: the index of the end of the branch + 1
    """
    pi = i
    i += 1
    while i < len(lst):
        if lst[i] <= lst[pi]:
            break
        i += 1
    return pi, i