title: Filter nested object based on deep value with Javascript
body: <p>I have this nested object:</p>
  <pre><code>const menus = { 
      path: '/actions/step',
      icon: 'fa fa-wine-bottle',
      title: 'Fasi',
      children: [
        {
          path: '/actions/step/analysis',
          title: 'Analisi'
        },
        {
          path: '/actions/step/import',
          title: 'Importazione'
        },
        {
          path: '/actions/step/squeeze',
          title: 'Spremitura'
        },
        {
          path: '/actions/step/move',
          title: 'Spostamento'
        },
        {
          path: '/actions/step/splitauto',
          title: 'Travaso Guidato'
        },
        {
          path: '/actions/step/stir',
          title: 'Rimestaggio'
        },
        {
          path: '/actions/step/clarify',
          title: 'Chiarifica'
        },
        {
          path: '/actions/step/stabilization',
          title: 'Stabilizzazione'
        },
        {
          path: '/actions/step/bottling',
          title: 'Imbottigliamento'
        },
        {
          path: '/actions/step/clean',
          title: 'Pulizia'
        },
        {
          path: '/actions/step/clean_close',
          title: 'Pulizia e Chiusura'
        },
        {
          path: '/actions/step/add_product',
          title: 'Aggiunta Prodotto'
        },
      ]
    },
    {
      path: '/actions',
      icon: 'fa fa-tasks',
      title: 'Azioni',
      children: [
        {
          path: '/actions/type',
          title: 'Tipi di Azione'
        },
        {
          path: '/actions/list',
          title: 'Lista delle Azioni'
        },
        {
          path: '/actions/traceability',
          title: 'Tracciabilità'
        }
      ]
    },
    { 
      path: '/warehouse', 
      icon: 'fa fa-warehouse', 
      title: 'Magazzino',
      children: [
        {
          path: '/warehouse/list-warehouse-item',
          title: 'Lista Oggetti',
          children: [
            {
              path: '/warehouse/new-warehouse-item',
              title: 'Nuovo Oggetto'
            }
          ]
        },
      ]
    },
    { 
      path: '/suppliers', 
      icon: 'fa fa-truck', 
      title: 'Fornitori',
      children: [
        {
          path: '/suppliers/list-suppliers',
          title: 'Lista Fornitori',
          children: [
            {
              path: '/suppliers/new-supplier',
              title: 'Nuovo Fornitore'
            }
          ]
        }
      ]
    }
  </code></pre>
  <p>What I'm trying to achieve is to filter the nested object based on the path value.</p>
  <p>So if I have <code>/actions/step/import</code> I would like to have this:</p>
  <pre><code>[{ 
      path: '/actions/step',
      icon: 'fa fa-wine-bottle',
      title: 'Fasi'
  },
  {
      path: '/actions/step/import',
      title: 'Importazione'
  }]
  </code></pre>
  <p>Or in case <code>/warehouse/new-warehouse-item</code> I would have:</p>
  <pre><code>[{ 
      path: '/warehouse', 
      icon: 'fa fa-warehouse', 
      title: 'Magazzino'
  },
  {
      path: '/warehouse/list-warehouse-item',
      title: 'Lista Oggetti'
  },
  {
      path: '/warehouse/new-warehouse-item',
      title: 'Nuovo Oggetto'
  }]
  </code></pre>
  <p>What I've tried to do is filtering like this way but it's incomplete (<code>this.$router.history.current.path</code> contains the string path):</p>
  <pre><code>menus.filter(menu =&gt; {
      if(menu.children){
          return menu.children.some(child =&gt; {
              if(child.children){
                  return child.children.some(nephew =&gt; {
                      return nephew.path === this.$router.history.current.path;
                  })
              } else {
                  return child.path === this.$router.history.current.path;
              }
          })
      } else {
          return menu.path === this.$router.history.current.path;
      }
  });
  </code></pre>