docs: public static <T, A, D> Collector<T, ?, D> maxAll(Comparator<? super T> comparator,
                                                        Collector<? super T, A, D> downstream) {
          Supplier<A> downstreamSupplier = downstream.supplier();
          BiConsumer<A, ? super T> downstreamAccumulator = downstream.accumulator();
          BinaryOperator<A> downstreamCombiner = downstream.combiner();
  
          /**
           * Container used to hold the accumulator and object
           */
          class Container {
              A acc;
              T obj;
              boolean hasAny;
  
              /**
               * Constructor.
               * @param acc accumulator
               */
              Container(A acc) {
                  this.acc = acc;
              }
          }
  
          Supplier<Container> supplier = () -> new Container(downstreamSupplier.get());
          BiConsumer<Container, T> accumulator = (acc, t) -> {
              if (!acc.hasAny) {
                  downstreamAccumulator.accept(acc.acc, t);
                  acc.obj = t;
                  acc.hasAny = true;
              } else {
                  int cmp = comparator.compare(t, acc.obj);
                  if (cmp > 0) {
                      acc.acc = downstreamSupplier.get();
                      acc.obj = t;
                  }
                  if (cmp >= 0) {
                      downstreamAccumulator.accept(acc.acc, t);
                  }
              }
          };
          BinaryOperator<Container> combiner = (acc1, acc2) -> {
              if (!acc2.hasAny) {
                  return acc1;
              }
              if (!acc1.hasAny) {
                  return acc2;
              }
              int cmp = comparator.compare(acc1.obj, acc2.obj);
              if (cmp > 0) {
                  return acc1;
              }
              if (cmp < 0) {
                  return acc2;
              }
              acc1.acc = downstreamCombiner.apply(acc1.acc, acc2.acc);
              return acc1;
          };
          Function<Container, D> finisher = acc -> downstream.finisher().apply(acc.acc);
          return Collector.of(supplier, accumulator, combiner, finisher);
      }