def visit_binary_product(fn, expr):
 stack = []
 def visit(element):
  if isinstance(element, ScalarSelect):
   (yield element)
  elif ((element.__visit_name__ == 'binary') and operators.is_comparison(element.operator)):
   stack.insert(0, element)
   for l in visit(element.left):
    for r in visit(element.right):
     fn(stack[0], l, r)
   stack.pop(0)
   for elem in element.get_children():
    visit(elem)
  else:
   if isinstance(element, ColumnClause):
    (yield element)
   for elem in element.get_children():
    for e in visit(elem):
     (yield e)
 list(visit(expr))

def visit_binary_product ( fn , expr ) : stack = [ ] def visit ( element ) : if isinstance ( element , ScalarSelect ) : ( yield element ) elif ( ( element . __visit_name__ == 'binary' ) and operators . is_comparison ( element . operator ) ) : stack . insert ( 0 , element ) for l in visit ( element . left ) : for r in visit ( element . right ) : fn ( stack [ 0 ] , l , r ) stack . pop ( 0 ) for elem in element . get_children ( ) : visit ( elem ) else : if isinstance ( element , ColumnClause ) : ( yield element ) for elem in element . get_children ( ) : for e in visit ( elem ) : ( yield e ) list ( visit ( expr ) )
produce a traversal of the given expression .