def flatten_iterator(x):
 for elem in x:
  if ((not isinstance(elem, str)) and hasattr(elem, '__iter__')):
   for y in flatten_iterator(elem):
    (yield y)
  else:
   (yield elem)

def flatten_iterator ( x ) : for elem in x : if ( ( not isinstance ( elem , str ) ) and hasattr ( elem , '__iter__' ) ) : for y in flatten_iterator ( elem ) : ( yield y ) else : ( yield elem )
given an iterator of which further sub-elements may also be iterators .