code: def assign_texts(node, words, next_idx=0):
      
      if len(node.children) == 0:
          node.text = words[next_idx]
          return next_idx + 1
      else:
          for child in node.children:
              next_idx = assign_texts(child, words, next_idx)
          return next_idx
docs: Recursively assign the words to nodes by finding and
      assigning strings to the leaves of a tree in left
      to right order.