title: Recursive function to generate flat array from hierarchical array Ruby
body: <p>I have a ruby hash array like this</p>
  
  <pre><code>string = "[{\"id\":13},{\"id\":15,\"children\":[{\"id\":16},{\"id\":17,\"children\":[{\"id\":19}]},{\"id\":18}]},{\"id\":14}]"
  hash = Json.parse(string)
  </code></pre>
  
  <p>I am trying to create an ruby hash array like:</p>
  
  <pre><code>{13=&gt;nil, 15=&gt;nil, 16=&gt;15, 17=&gt;15, 19=&gt;17, 18=&gt;15, 14=&gt;nil}
  </code></pre>