def _nearest_ancestor_table(element):
    """
    Given a BeautifulSoup element, returns the nearest ancestor 
    <table> of that element, not including the supplied element 
    itself.
    """
    for ancestor in element.parents:
        if ancestor.name == 'table':
            return ancestor
    raise ValueError('Element has no <table> ancestor!')
