'Makes the given element the immediate predecessor of this one.
The two elements will have the same parent, and the given element
will be immediately before this one.'

def insert_before(self, predecessor):

    if (self is predecessor):
        raise ValueError("Can't    insert    an    element    before    itself.")
    parent = self.parent
    if (parent is None):
        raise ValueError("Element    has    no    parent,    so    'before'    has    no    meaning.")
    if isinstance(predecessor, PageElement):
        predecessor.extract()
    index = parent.index(self)
    parent.insert(index, predecessor)
