code: @Nullable
      public <R> R reduce(@Nullable R identity,
                          @NotNull BiFunction<? super R, ? super T, ? extends R> accumulator) {
          R result = identity;
          while (iterator.hasNext()) {
              final T value = iterator.next();
              result = accumulator.apply(result, value);
          }
          return result;
      }
docs: Reduces the elements using provided identity value and the associative accumulation function.
  
  <p>This is a terminal operation.
  
  <p>Example:
  <pre>
  identity: 0
  accumulator: (a, b) -&gt; a + b
  stream: [1, 2, 3, 4, 5]
  result: 15
  </pre>
  
  @param <R> the type of the result
  @param identity  the initial value
  @param accumulator  the accumulation function
  @return the result of the reduction