def _ensure_term(where, scope_level):
 level = (scope_level + 1)
 if isinstance(where, (list, tuple)):
  wlist = []
  for w in filter((lambda x: (x is not None)), where):
   if (not maybe_expression(w)):
    wlist.append(w)
   else:
    wlist.append(Term(w, scope_level=level))
  where = wlist
 elif maybe_expression(where):
  where = Term(where, scope_level=level)
 return where

def _ensure_term ( where , scope_level ) : level = ( scope_level + 1 ) if isinstance ( where , ( list , tuple ) ) : wlist = [ ] for w in filter ( ( lambda x : ( x is not None ) ) , where ) : if ( not maybe_expression ( w ) ) : wlist . append ( w ) else : wlist . append ( Term ( w , scope_level = level ) ) where = wlist elif maybe_expression ( where ) : where = Term ( where , scope_level = level ) return where
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 .