def __init__()

in utils/trees.py [0:0]


    def __init__(self, *, flat_string=None, tree_rep=None, root_symbol=None, children=None):
        '''
        This construtor is used to instantiate an object of derived classes
        using either a flat string `flat_string`, a tree representation
        `tree_rep`, or the combination of a root symbol and a list of tree_rep children.

        :param flat_string: (str) input flat string to construct a tree, if possible.
        :param tree_rep: (AnyNode) a tree.
        :param root_symbol: (str) a string that will be used as id of root node.
        :param children: (list) a list of SemanticTree objects to be defined as children of root_symbol.
        '''
        try:
            # we pass `flat_string` when we instantiate an object of "Tree" class
            # when no underlying Tree representation is currently existing, i.e we
            # create an object from ground up. 
            if flat_string:
                self.tree_rep = self._linearized_rep_to_tree_rep(flat_string)
            # we pass `tree_rep` when we instantiate an object of a derived class
            # when an underlying Tree representation already exists but we want to
            # have a new tree representation from an existing one.
            elif tree_rep:
                self.tree_rep = tree_rep
            # we pass root_symbol and children when we want to construct a new tree
            # object from a list of valid tree children and a symbol for the parent root node.
            elif root_symbol and children:
                self.tree_rep = AnyNode(id=root_symbol, children=[c.tree_rep for c in children])

        except Exception as e:
            raise ValueError() from e