FpKit now longer uses streams for performance reasons by bbakerman · Pull Request #3932 · graphql-java/graphql-java

This comment above explains the whacky code. One less map allocation

public static <T, NewKey> Map<NewKey, ImmutableList<T>> groupingBy(Collection<T> list, Function<T, NewKey> function) {
        Map<NewKey, ImmutableList.Builder<T>> tempMap = new LinkedHashMap<>();
        for (T item : list) {
            NewKey key = function.apply(item);
            tempMap.computeIfAbsent(key, k -> ImmutableList.builder()).add(item);
        }
        Map<NewKey, ImmutableList<T>> resultMap = new LinkedHashMap<>();
        for (Map.Entry<NewKey, ImmutableList.Builder<T>> entry : tempMap.entrySet()) {
            resultMap.put(entry.getKey(), entry.getValue().build());
        }
        return resultMap;
    }