code: public static <T> Stream<T> unfold(T seed, Function<T, Optional<T>> generator) {
          return StreamSupport.stream(UnfoldSpliterator.over(seed, generator), false);
      }
docs: Construct a stream which takes the seed value and applies the generator to create the next value, feeding each
  new value back into the generator to create subsequent values. If the generator returns Optional.empty(), then
  the stream has no more values.
  @param seed The seed value.
  @param generator The generator to use to create new values.
  @param <T> The type over which the stream streams.
  @return An unfolding stream.