title: mapValues on innermost map of nested maps
body: <p>This inspiration for this question came when I tried to answer <a href="https://stackoverflow.com/questions/5843849/what-to-do-with-operations-for-a-specific-kind-of-collection">this one</a>.</p>
  
  <p>Say you have a sequence of data (may be from a CSV file for instance). <code>groupBy</code> can be used to analyze certain aspect of the data, grouping by column or a combination of columns. For instance:</p>
  
  <pre><code>val groups0: Map[String, Array[String]] = 
    seq.groupBy(row =&gt; row(0) + "-" + row(4))
  </code></pre>
  
  <p>If I then want to create sub-groups within the groups I can do </p>
  
  <pre><code>val groups1: Map[String, Map[String, Array[String]]] = 
    groups0.mapValues(row =&gt; row.groupBy(_(1))
  </code></pre>
  
  <p>If I want to do this more one time it gets really cumbersome:</p>
  
  <pre><code>val groups2 = 
    groups1.mapValues(groups =&gt; groups.mapValues(row =&gt; row.groupBy(_(2)))
  </code></pre>
  
  <p>So here is my question given an arbitrary nesting of <code>Map[K0, Map[K1, ..., Map[Kn, V]]]</code>, how do you write a <code>mapValues</code> function that takes a <code>f: (V) =&gt; B</code> and applies to the innermost <code>V</code> to return a <code>Map[K0, Map[K1, ..., Map[Kn, B]]]</code>?</p>