def _ensure_term(where, scope_level):
<EOL>level = scope_level + <NUM_LIT:1><EOL>if isinstance(where, (list, tuple)):<EOL><INDENT>wlist = []<EOL>for w in filter(lambda x: x is not None, where):<EOL><INDENT>if not maybe_expression(w):<EOL><INDENT>wlist.append(w)<EOL><DEDENT>else:<EOL><INDENT>wlist.append(Term(w, scope_level=level))<EOL><DEDENT><DEDENT>where = wlist<EOL><DEDENT>elif maybe_expression(where):<EOL><INDENT>where = Term(where, scope_level=level)<EOL><DEDENT>return where<EOL>
ensure that the where is a Term or a list of Term
this makes sure that we are capturing the scope of variables
that are passed
create the terms here with a frame_level=2 (we are 2 levels down)