title: How to add an object to a nested javascript object using a parent id
body: <p>In my application I create a JavaScript object based on a JSON response from the server similar to this:</p>
  
  <pre><code>{
    name: "root",
    id: 1,
    children: [
      {
        name: "child one",
        id: 11,
        children: [
         {name: "grand child 1", id: 111, children: []},
         {name: "grand child 2", id: 112, children: []}
        ]
     },
     {
       name: "child two",
       id: 12,
       children: []
     }
    ]
  }
  </code></pre>
  
  <p>I create a new node such as:</p>
  
  <pre><code> {name: "grandchild three", id: 113, children:[]}
  </code></pre>
  
  <p>With this in mind, how can I add this new grandchild to its parent with id 11? Please note that I don’t know the static path to node with <code>id == 11</code> so I am wondering how I could obtain that node with just knowing it's <code>id</code>.</p>
  
  <p><strong>Edit:</strong> please note the id's in the real case do NOT encode the path to objects. I created this simple example for demonstration of the data structure I am dealing with. But I can not retrieve the path to the object using its id in my real application.</p>