code: def flatMap(self, f, preservesPartitioning=False):
          def func(s, iterator):
              return chain.from_iterable(map(fail_on_stopiteration(f), iterator))
          return self.mapPartitionsWithIndex(func, preservesPartitioning)