'Remove the node from the tree. Returns the position of the node in its
parent\'s children before it was removed.'

def remove(self):

    if self.parent:
        for (i, node) in enumerate(self.parent.children):
            if (node is self):
                self.parent.changed()
                del self.parent.children[i]
                self.parent = None
                return i
