code: def recgen_enumerate(gen,n=tuple(), fix_type_errors=True):
      
      if not hasattr(gen,'__iter__'):
          yield (n,gen)
      else:
          try:
              for i_,i in enumerate(gen):
                  for element in recgen_enumerate(i,n+(i_,)):
                      yield element
          except TypeError:
              if not fix_type_errors:
                  raise
              yield (n,gen)
docs: Iterates through generators recursively and flattens them. (see `recgen`)
  
          This function adds a tuple with enumerators on each generator visited.