'Replace this node with a new one in the parent.'

def replace(self, new):

    if (not isinstance(new, list)):
        new = [new]
    l_children = []
    found = False
    for ch in self.parent.children:
        if (ch is self):
            if (new is not None):
                l_children.extend(new)
            found = True
        else:
            l_children.append(ch)
    self.parent.changed()
    self.parent.children = l_children
    for x in new:
        x.parent = self.parent
    self.parent = None
    return
