title: Javascript - Nested parent/child array recursive function that flattens parent only
body: <p>I have a multidimensional nested parent/child array as follows: </p>
  
  <pre><code>{
    parent: {
       name: "foo"
    },
    children: [
      {
        parent: {
           name: "asdf",
        },
        children: []
      },
      {
       parent: {},
       children: []
      },
      {
       parent: {},
       children: []
      },
      ...
    ]
  }
  </code></pre>
  
  <p>What I want to do is apply a recursive function on this array, to flatten only the parent property and keep children as-is, in order to get something like this:</p>
  
  <pre><code> {
    name: "foo",
    children: [
      {
        name: "asdf",
        children: []
      },
      {
       children: []
      },
      {
       children: []
      },
      ...
    ]
  }
  </code></pre>
  
  <p>I tried using underscore.js but I am unable to find a recursive function that could do the trick. Any thoughts?</p>