'Destructively rips this element out of the tree.'

def extract(self):

    if (self.parent is not None):
        del self.parent.contents[self.parent.index(self)]
    last_child = self._last_descendant()
    next_element = last_child.next_element
    if ((self.previous_element is not None) and (self.previous_element != next_element)):
        self.previous_element.next_element = next_element
    if ((next_element is not None) and (next_element != self.previous_element)):
        next_element.previous_element = self.previous_element
    self.previous_element = None
    last_child.next_element = None
    self.parent = None
    if ((self.previous_sibling is not None) and (self.previous_sibling != self.next_sibling)):
        self.previous_sibling.next_sibling = self.next_sibling
    if ((self.next_sibling is not None) and (self.next_sibling != self.previous_sibling)):
        self.next_sibling.previous_sibling = self.previous_sibling
    self.previous_sibling = self.next_sibling = None
    return self
