title: GroupBy and merge into a single list in java
body: <p>Java 8 provides a groupingBy function in Collectors, but it gives a map of elements. I need to convert the map into a single list. </p>
  
  <p>Also it returns the result, but instead what I want is to perform the grouping operation to the list itself so that I do not have to reassign it, as reassigning is not possible in a lambda expression.</p>
  
  <p>How can I achieve this?</p>
  
  <p>I want to achieve this:</p>
  
  <pre><code>Map&lt;String, List&lt;Node&gt;&gt; nodeListGrouped = nodeList.stream().collect(Collectors.groupingBy(node -&gt; node.getGroupName()));
  </code></pre>
  
  <p>convert nodeListGrouped into a single List</p>
  
  <p>But nodeListGrouped.values() returns Collection(List)</p>