code: def unnest(elem):
      
  
      if isinstance(elem, Iterable) and not isinstance(elem, six.string_types):
          elem, target = tee(elem, 2)
      else:
          target = elem
      for el in target:
          if isinstance(el, Iterable) and not isinstance(el, six.string_types):
              el, el_copy = tee(el, 2)
              for sub in unnest(el_copy):
                  yield sub
          else:
              yield el
docs: Flatten an arbitrarily nested iterable
  
      :param elem: An iterable to flatten
      :type elem: :class:`~collections.Iterable`
  
      >>> nested_iterable = (1234, (3456, 4398345, (234234)), (2396, (23895750, 9283798, 29384, (289375983275, 293759, 2347, (2098, 7987, 27599)))))
      >>> list(vistir.misc.unnest(nested_iterable))
      [1234, 3456, 4398345, 234234, 2396, 23895750, 9283798, 29384, 289375983275, 293759, 2347, 2098, 7987, 27599]