title: Recursive function with an Object in JS
body: <p>I have an array that contains objects that might have nth levels of depth.</p>
  
  <p>Something like this:</p>
  
  <pre><code>const settings = [
  
      {path: '/templates/pictures.php', url: '/pictures', label: 'Pictures', component: 'tab', template: 'default'},
      {path: '/templates/post-article.php', url: '/user/:username', component: 'table', template: 'default', children:[
          {path: '/templates/post-article-highlights.php', url: '/user/:username/highlights', component: 'table', template: 'default', children:[
                {path: '/templates/post-article-highlights.php', url: '/user/:username/highlights', component: 'table', template: 'default'}  
  
          ]}  
      ]}
  
  ]
  </code></pre>
  
  <p>I need to push on a different array only the 'Url' property and the children property if present, preserving the depth though.</p>
  
  <p>So the new array should look like this:</p>
  
  <pre><code>const newArray = [
  
      {url: '/pictures'},
      {url: '/user/:username', children:[
          {url: '/user/:username/highlights', children:[
                  {url: '/user/:username/highlights'} 
          ]}  
      ]}
  
  ]
  </code></pre>
  
  <p>Can you help me?</p>
  
  <p>Thanks</p>