def is_valid_join_expression(self, expr):

        def joining_tables(table):
            for fk in self.db.all_joins(table):
                yield fk.table if table != fk.table else fk.reftable
        if '**' not in expr:
            return False
        tables = expr.split('**')
        valid = True
        while len(tables) > 1:
            tail = tables.pop()
            jointables = joining_tables(tail)
            valid = bool(set(jointables) & set(tables))
            if not valid:
                break
        return valid
dataset/ETHPy150Open jaysw/ipydb/ipydb/completion.py/IpydbCompleter.is_valid_join_expression/original