def iterate(obj, opts):
 children = obj.get_children(**opts)
 if (not children):
  return [obj]
 traversal = deque()
 stack = deque([obj])
 while stack:
  t = stack.popleft()
  traversal.append(t)
  for c in t.get_children(**opts):
   stack.append(c)
 return iter(traversal)

def iterate ( obj , opts ) : children = obj . get_children ( ** opts ) if ( not children ) : return [ obj ] traversal = deque ( ) stack = deque ( [ obj ] ) while stack : t = stack . popleft ( ) traversal . append ( t ) for c in t . get_children ( ** opts ) : stack . append ( c ) return iter ( traversal )
traverse the given expression structure .