title: Reduce array of arrays and remove null from Javascript data
body: <p>I am having difficulty &quot;compressing&quot; the results of my grammar by stripping out null values and embedded arrays using Javascript.
  I am using the Nearley grammar checker which can run JS functions after a sentence is matched.  Unfortunately you get the results of the full parse as a series of arrays.  The following is an example of the output</p>
  <pre><code>[
     [
        [
           [
              [
                 [
                    [ [ 'climb'], [ [ null, 'to' ] ] ],
                    [ [ null, [ 'alt' ] ] ],
                    [ 332, [ null, [ 'km' ] ] ]
                 ]
              ],
              [ null ]
           ]
        ]
     ]
  ]
  </code></pre>
  <p>I would like to remove all those <code>null</code> values and possibly &quot;compress&quot; all those arrays to something of the form:</p>
  <pre><code>[
     [ 'climb', 'to' ],
     [ 'alt', 332, 'km' ]
  ]
  </code></pre>
  <p>Or something similar.  I have tried using various <code>filter</code> methods without success.</p>