title: How to collect items in a list of maps in Scala
body: <p>If I have a sequence of maps with repeating values and sub maps that look like this:</p>
  
  <pre><code>val from = Seq(
      Map("aaa" -&gt; Map("bbb" -&gt; Map("ccc" -&gt; List(1)))),
      Map("aaa" -&gt; Map("bbb" -&gt; Map("ddd" -&gt; List("a","b")))),
      Map("aaa" -&gt; Map("bbb" -&gt; Map("eee" -&gt; List(99,100)))),
      Map("aaa" -&gt; Map("bbb" -&gt; Map("ccc" -&gt; List(2,3)))),
      Map("aaa" -&gt; Map("bbb" -&gt; Map("ddd" -&gt; List("c","d")))),
      Map("aaa" -&gt; Map("bbb" -&gt; Map("eee" -&gt; List(101,102)))),
      Map("aaa" -&gt; Map("bbb" -&gt; Map("ccc" -&gt; Map("ddd" -&gt; Map("eee" -&gt; Map("fff" -&gt; Map("ggg" -&gt; List(true, false)))
      ))))))
  </code></pre>
  
  <p>What is the Scala way to converting it into a collated structure that looks like this:</p>
  
  <pre><code>val to = Seq(
      Map("aaa" -&gt;
        Map("bbb" -&gt; Map(
          "ccc" -&gt; List(1, 2, 3),
          "ddd" -&gt; List("a", "b", "c", "d"),
          "eee" -&gt; List(99, 100, 101, 102),
          "fff" -&gt; 
              Map("ggg" -&gt; List(true, false))
        )
      )
    )
  )
  </code></pre>