'annotate \'remote\' in primaryjoin, secondaryjoin
when the relationship is detected as self-referential.'

def _annotate_selfref(self, fn):

    def visit_binary(binary):
        equated = binary.left.compare(binary.right)
        if (isinstance(binary.left, expression.ColumnClause) and isinstance(binary.right, expression.ColumnClause)):
            if fn(binary.left):
                binary.left = binary.left._annotate({'remote': True})
            if (fn(binary.right) and (not equated)):
                binary.right = binary.right._annotate({'remote': True})
        else:
            self._warn_non_column_elements()
    self.primaryjoin = visitors.cloned_traverse(self.primaryjoin, {}, {'binary': visit_binary})
