title: Remove duplicates between different array dimensions
body: <p>I have a table in the database with navbar menu items, this table has a relationship 1xN with itself, I'm retrieving the data (like: <code>\App\Menu::with(['childs'])-&gt;get()</code>) as:</p>
  
  <pre><code>array(
      array(
          'id' =&gt; 1,
          'id_parent' =&gt; NULL,
          'url' =&gt; '/',
          'childs' =&gt; array ()
      ),
      array(
          'id' =&gt; 2,
          'id_parent' =&gt; NULL,
          'url' =&gt; '/blog',
          'childs' =&gt; array (
              array(
                  'id' =&gt; 3,
                  'id_parent' =&gt; 2,
                  'url' =&gt; 'blog/kitchen',
                  'childs' =&gt; array(
                      array(
                          'id' =&gt; 4,
                          'id_parent' =&gt; 3,
                          'url' =&gt; 'blog/kitchen/salads',
                          'childs' =&gt; array()
                      ),
                      array(
                          'id' =&gt; 5,
                          'id_parent' =&gt; 3,
                          'url' =&gt; 'blog/kitchen/soups',
                          'childs' =&gt; array()
                      ),
                  )
              ),
          )
      ), 
      array(
          'id' =&gt; 3,
          'id_parent' =&gt; 2,
          'url' =&gt; '/blog/kitchen',
          'childs' =&gt; array()
      ),
      array(
          'id' =&gt; 4,
          'id_parent' =&gt; 3,
          'url' =&gt; 'blog/kitchen/salads',
          'childs' =&gt; array()
      ),
      array(
          'id' =&gt; 5,
          'id_parent' =&gt; 3,
          'url' =&gt; 'blog/kitchen/soups',
          'childs' =&gt; array()
      ),
  );
  </code></pre>
  
  <p>What I need:</p>
  
  <pre><code>array(
      array(
          'id' =&gt; 1,
          'id_parent' =&gt; NULL,
          'url' =&gt; '/',
          'childs' =&gt; array ()
      ),
      array(
          'id' =&gt; 2,
          'id_parent' =&gt; NULL,
          'url' =&gt; '/blog',
          'childs' =&gt; array (
              array(
                  'id' =&gt; 3,
                  'id_parent' =&gt; 2,
                  'url' =&gt; 'blog/kitchen',
                  'childs' =&gt; array(
                      array(
                          'id' =&gt; 4,
                          'id_parent' =&gt; 3,
                          'url' =&gt; 'blog/kitchen/salads',
                          'childs' =&gt; array()
                      ),
                      array(
                          'id' =&gt; 5,
                          'id_parent' =&gt; 3,
                          'url' =&gt; 'blog/kitchen/soups',
                          'childs' =&gt; array()
                      ),
                  )
              ),
          )
      ),
  );
  </code></pre>
  
  <p>If there is an easier way, like; <code>SELECT</code> directly in the database it would be great, if not, just removing the inner items from the outer layer with PHP is enough.</p>