'Return the leaf node that precedes this node in the parse tree.'

def get_prev_leaf(self):

    def last_child(node):
        if isinstance(node, Leaf):
            return node
        elif (not node.children):
            return None
        else:
            return last_child(node.children[(-1)])
    if (self.parent is None):
        return None
    prev = self.get_prev_sibling()
    if isinstance(prev, Leaf):
        return prev
    elif (prev is not None):
        return last_child(prev)
    return self.parent.get_prev_leaf()
