title: Apply a function to a nested list grouped by stream
body: <p>There is a list of objects for the following class:</p>
  
  <pre><code>class A {
     String firstName;
     String lastName;
     //.....
  }
  </code></pre>
  
  <p>There is also a method that takes in three parameters: </p>
  
  <pre><code>List&lt;B&gt; someMethod(String firstName, String lastName, List&lt;A&gt; l);
  </code></pre>
  
  <p>I want to group this list based on <code>firstName</code> and <code>lastName</code> and then apply this method to the items in the list of items that have <code>firstName</code> and <code>lastName</code> </p>
  
  <p>I tried the following: </p>
  
  <pre><code>Map&lt;String, Map&lt;String, List&lt;B&gt;&gt;&gt; groupedItems = l.stream()
       .collect(groupingBy(A::getFirstName, groupingBy(A::getLastName)));
  
  List&lt;B&gt; result = groupedItems.keySet().stream()
       .map(firstName -&gt; groupedItems.get(firstName).keySet().stream()
               .map(lastName -&gt; someMethod(firstName, lastName, groupedItems.get(firstName).get(lastName))
               .collect(Collectors.toList()))
       .flatMap(Collection::stream)
       .collect(Collectors::toList);
  </code></pre>
  
  <p>Is there a way to do this in one shot instead of the way it is now? </p>