'Compare this ColumnElement to another.
Special arguments understood:
:param use_proxies: when True, consider two columns that
share a common base column as equivalent (i.e. shares_lineage())
:param equivalents: a dictionary of columns as keys mapped to sets
of columns. If the given "other" column is present in this
dictionary, if any of the columns in the corresponding set() pass the
comparison test, the result is True. This is used to expand the
comparison to other columns that may be known to be equivalent to
this one via foreign key or other criterion.'

def compare(self, other, use_proxies=False, equivalents=None, **kw):

    to_compare = (other,)
    if (equivalents and (other in equivalents)):
        to_compare = equivalents[other].union(to_compare)
    for oth in to_compare:
        if (use_proxies and self.shares_lineage(oth)):
            return True
        elif (hash(oth) == hash(self)):
            return True
    else:
        return False
