code: public <V extends Comparable<? super V>> Optional<T> maxBy(Function<? super T, ? extends V> keyExtractor) {
          return Box
                  .asOptional(reduce(null, (PairBox<T, V> acc, T t) -> {
                      V val = keyExtractor.apply(t);
                      if (acc == null)
                          return new PairBox<>(t, val);
                      if (val.compareTo(acc.b) > 0) {
                          acc.b = val;
                          acc.a = t;
                      }
                      return acc;
                  }, (PairBox<T, V> acc1, PairBox<T, V> acc2) -> (acc1 == null || acc2 != null
                      && acc1.b.compareTo(acc2.b) < 0) ? acc2 : acc1));
      }
docs: Returns the maximum element of this stream according to the natural order
  of the keys extracted by provided function. This is a special case of a
  reduction.
  
  <p>
  This is a terminal operation.
  
  <p>
  This method is equivalent to
  {@code max(Comparator.comparing(keyExtractor))}, but may work faster as
  keyExtractor function is applied only once per each input element.
  
  @param <V> the type of the comparable keys
  @param keyExtractor a <a
  href="package-summary.html#NonInterference">non-interfering </a>,
  <a href="package-summary.html#Statelessness">stateless</a>
  function to extract the comparable keys from this stream elements
  @return an {@code Optional} describing the maximum element of this
  stream, or an empty {@code Optional} if the stream is empty
  @throws NullPointerException if the maximum element is null