title: Threaded App.net Conversation Into Tree
body: <p>I want to create a JSON tree from a flat structure - in this case an App.net Thread.</p>
  
  <p>I want JSON like this</p>
  
  <pre><code>"id": "12345",
  "name": "Ringo",
      "data": 
      {
          "avatar": "",
          "text": "We All Live",
      },
      "children": [{
          "id": "34567",
          "name": "John",    
          "data": 
          {
              "avatar": "",
              "text": "In a pink submarine?",
          },
          "children": [{
              "id": "35555",
              "name": "George",    
              "data": 
              {
                  "avatar": "",
                  "text": "Don't be daft",
              },
              "children": []
          }]
      },{
          "id": "98765",
          "name": "Paul",    
          "data": 
          {
              "avatar": "",
              "text": "In a yellow submarine?",
          },
          "children": []
      }]
  </code></pre>
  
  <p>So, each post can have multiple children. Each child can have children.</p>
  
  <p>The JSON coming back from App.net is <strong>not</strong> threaded.</p>
  
  <pre><code>{
      "id": "98765",
      "parent": "12345"
      "details": {
      ...}
  },
  {
      "id": "34567",
      "parent": "12345"
      "details": {
      ...}
  },
  </code></pre>
  
  <p>I've used json_decode() to get the JSON response in to an array.  I can iterate through using foreach.</p>
  
  <p>How do I put each post in the correct part of the multi dimensional array?</p>
  
  <pre><code>Parent
  |_
    |-child
    |-child
    |  |-child
    |-child
  </code></pre>
  
  <p>etc</p>