'Return True if the join condition contains column
comparisons where both columns are in both tables.'

def _refers_to_parent_table(self):

    pt = self.parent_selectable
    mt = self.child_selectable
    result = [False]
    def visit_binary(binary):
        (c, f) = (binary.left, binary.right)
        if (isinstance(c, expression.ColumnClause) and isinstance(f, expression.ColumnClause) and pt.is_derived_from(c.table) and pt.is_derived_from(f.table) and mt.is_derived_from(c.table) and mt.is_derived_from(f.table)):
            result[0] = True
    visitors.traverse(self.primaryjoin, {}, {'binary': visit_binary})
    return result[0]
