def insert(self, name, attr=None):
        """Insert a new tag into the current one. The name can be either the
        new tag name or an XMLstruct object (in which case attr is ignored).
        Unless name is None, we descend into the new tag as a side effect.
        A dictionary is expected for attr."""
        if not self.current.hasSubtag():
            self.current.tag['Icontain'] = []
        if name == None:
            # empty subtag list inserted, return now
            # (this produces <tag></tag> in the output)
            return
        elif type(name) == str:
            # create a new subtag with given name and attributes
            newtag = XMLstruct(name, attr)
        else:
            # input assumed to be a tag structure
            newtag = name
        self.current.tag['Icontain'].append(newtag)
        self.stack.append(self.current)
        self.current = newtag
dataset/ETHPy150Open pybrain/pybrain/pybrain/rl/environments/ode/tools/xmltools.py/XMLstruct.insert/original