def find_all_base_tables(expr, memo=None):
    if (memo is None):
        memo = {}
    node = expr.op()
    if (isinstance(expr, ir.TableExpr) and node.blocks()):
        if (expr not in memo):
            memo[node] = expr
        return memo
    for arg in expr.op().flat_args():
        if isinstance(arg, ir.Expr):
            find_all_base_tables(arg, memo)
    return memo
def find_all_base_tables(expr, memo=None):
    if (memo is None):
        memo = {}
    node = expr.op()
    if (isinstance(expr, ir.TableExpr) and node.blocks()):
        if (expr not in memo):
            memo[node] = expr
        return memo
    for arg in expr.op().flat_args():
        if isinstance(arg, ir.Expr):
            find_all_base_tables(arg, memo)
    return memo