def create_tree(B, left, right, non_terminal, sent):
    """
    This is a recursive function that creates a nested list structure for parse tree

    Args:
        B (dict): Stores backppointers
        left (int): starting index of a consituent
        right ([type]): ending index of a consituent
        non_terminal (str): tag associated with the constituent
        sent (list): list of words in the sentence

    Returns:
        list: Nested list representation of a parse tree

    Example:
        For input sentence: "Her creditor makes a barrier"
        Return value of create_tree: ['S', ['NP', ['PRP$', 'Her'], ['NN', 'creditor']], ['VP', ['VBZ', 'makes'], ['NP', ['DT', 'a'], ['NN', 'barrier']]]]
    """
    if left<0 or left>=right:
        return None
        
    if left == right-1:
        return [non_terminal, sent[left]]

    split, left_tag, right_tag = B[non_terminal][left][right]
    left_ans = create_tree(B, left, split, left_tag, sent) 
    right_ans = create_tree(B, split, right, right_tag, sent)
    return [non_terminal, left_ans, right_ans]