nodes: 0, module; 1, function_definition; 2, function_name:add; 3, parameters; 4, block; 5, identifier:self; 6, identifier:text; 7, default_parameter; 8, default_parameter; 9, expression_statement; 10, if_statement; 11, expression_statement; 12, expression_statement; 13, return_statement; 14, identifier:checked; 15, False; 16, identifier:sort; 17, None; 18, comment:"""Add a new sub item to the list. This item must already be attached to a list.
  
          Args:
              text (str): The text.
              checked (bool): Whether this item is checked.
              sort (int): Item id for sorting.
          """; 19, comparison_operator:self.parent is None; 20, block; 21, assignment; 22, call; 23, identifier:node; 24, attribute; 25, None; 26, raise_statement; 27, identifier:node; 28, call; 29, attribute; 30, argument_list; 31, identifier:self; 32, identifier:parent; 33, call; 34, attribute; 35, argument_list; 36, identifier:self; 37, identifier:indent; 38, identifier:node; 39, attribute; 40, argument_list; 41, attribute; 42, identifier:add; 43, identifier:text; 44, identifier:checked; 45, identifier:sort; 46, identifier:exception; 47, identifier:InvalidException; 48, string; 49, identifier:self; 50, identifier:parent; 51, string_content:Item has no parent
code: def add(self, text, checked=False, sort=None):
          """Add a new sub item to the list. This item must already be attached to a list.
  
          Args:
              text (str): The text.
              checked (bool): Whether this item is checked.
              sort (int): Item id for sorting.
          """
          if self.parent is None:
              raise exception.InvalidException('Item has no parent')
          node = self.parent.add(text, checked, sort)
          self.indent(node)
          return node