code: def read_tree(parents, labels, words):
      
      trees = {}
      root = None
      for i in range(1, len(parents) + 1):
          if not i in trees and parents[i - 1] != - 1:
              idx = i
              prev = None
              while True:
                  parent = parents[idx - 1]
                  if parent == -1:
                      break
                  tree = LabeledTree()
                  if prev is not None:
                      tree.add_child(prev)
                  trees[idx] = tree
                  tree.label = labels[idx - 1]
                  if trees.get(parent) is not None:
                      trees[parent].add_child(tree)
                      break
                  elif parent == 0:
                      root = tree
                      break
                  else:
                      prev = tree
                      idx = parent
      assert assign_texts(root, words) == len(words)
      return root
docs: Take as input a list of integers for parents
      and labels, along with a list of words, and
      reconstruct a LabeledTree.