def get_top_parent(element, root):
    """Get and return closest to root parent of the element"""
    parent = element
    while parent.parent != root:
        parent = parent.parent
        if parent is None:
            return
    return parent
