Collectors.toMap vs. Collectors.groupingBy - toMap problem with not unique key in provided data : Code snippet:
-------------

    Map<Integer, Map<String, Integer>> collect = shopping.entrySet()
                .stream()
                .collect(Collectors.toMap/*groupingBy? */(e -> e.getKey().getAge(),
                        e -> e.getValue().entrySet().stream().collect(Collectors.groupingBy(b -> b.getKey().getCategory(), Collectors.summingInt(Map.Entry::getValue)))));


The problem comes from a fact, that the provided data **contains multiple values by key** - there are Clients with same ages, and the code works only for a single value by key.

How could I make this code work also for multiple keys. I suppose it should be somehow changed to use collect `collect(Collectors.groupingBy)` ->  

    Map<Integer, Map<String, Integer>> collect = shopping.entrySet()
                .stream()
                .collect(Collectors.groupingBy(/*...*/))

Shopping is basically a map: `Map <Client, Map <Product,Integer>>`, **Integer** indicates the number of product bought by specified Client