class CollectionFunctions {

    public static <T, R, S> Map<S, Map<T,R>> simpleGroupBy(Map<T, R> map, Function<T, S> filterFn) {
        Map<S, List<Entry<T, R>>> intermediate = map.entrySet().stream().collect(groupingBy(e -> filterFn.apply(e.getKey())));
        return simpleMapKeyAndValue(intermediate, identity(), value -> simpleToMap(value, Entry::getKey, Entry::getValue));
    }

    private  CollectionFunctions();

}