code: def create_tree_from_string(line):
      
      depth         = 0
      current_word  = ""
      root          = None
      current_node  = root
  
      for char in line:
          if char == '(':
              if current_node is not None and len(current_word) > 0:
                  attribute_text_label(current_node, current_word)
                  current_word = ""
              depth += 1
              if depth > 1:
                  # replace current head node by this node:
                  child = LabeledTree(depth=depth)
                  current_node.add_child(child)
                  current_node = child
                  root.add_general_child(child)
              else:
                  root = LabeledTree(depth=depth)
                  root.add_general_child(root)
                  current_node = root
  
          elif char == ')':
              # assign current word:
              if len(current_word) > 0:
                  attribute_text_label(current_node, current_word)
                  current_word = ""
  
              # go up a level:
              depth -= 1
              if current_node.parent != None:
                  current_node.parent.udepth = max(current_node.udepth+1, current_node.parent.udepth)
              current_node = current_node.parent
          else:
              # add to current read word
              current_word += char
      if depth != 0:
          raise ParseError("Not an equal amount of closing and opening parentheses")
  
      return root
docs: Parse and convert a string representation
      of an example into a LabeledTree datastructure.
  
      Arguments:
      ----------
          line : str, string version of the tree.
  
      Returns:
      --------
          LabeledTree : parsed tree.