title: Get multidimensional array from ordered list
body: <p>I have a simple nested list.</p>
  <pre><code>&lt;ol id=&quot;draggable&quot; class=&quot;nested-sort&quot;&gt;
      &lt;li data-id=&quot;1&quot;&gt;Lion&lt;/li&gt;
      &lt;li data-id=&quot;2&quot;&gt;Snake&lt;/li&gt;
      &lt;li data-id=&quot;3&quot;&gt;Butterfly
          &lt;ol data-id=&quot;3&quot;&gt;
              &lt;li data-id=&quot;31&quot;&gt;Fish&lt;/li&gt;
              &lt;li data-id=&quot;32&quot;&gt;Cat&lt;/li&gt;
              &lt;li data-id=&quot;33&quot;&gt;Monkey&lt;/li&gt;
          &lt;/ol&gt;
      &lt;/li&gt;
      &lt;li data-id=&quot;4&quot;&gt;Parrot&lt;/li&gt;
  &lt;/ol&gt;
  </code></pre>
  <p>I want to get all IDs of the <code>&lt;li&gt;</code> as a multidimensional array. Therefore I tried to used jQuery's <code>.each()</code>, but that returns only one iteration.</p>
  <pre><code>$( &quot;#draggable li&quot; ).each(function( index ) {
      console.log( index + &quot;: &quot; + $( this ).text() );
  });
  </code></pre>
  <p>That results in the following output:</p>
  <pre><code>0: Lion
  1: Snake
  2: Butterfly                                                
    Fish
    Cat
    Monkey
  3: Fish
  4: Cat
  5: Monkey
  6: Parrot
  </code></pre>