title: How to handle tree-shaped entities in Redux reducers?
body: <p>I'm a bit stuck thinking on how to implement a reducer where its entities can have children of the same type.</p>
  
  <p>Let's take reddit comments as an example: each comment can have child comments that can have comments themselves etc.
  For simplification reason, a comment is a record of type <code>{id, pageId, value, children}</code>, with <code>pageId</code> being the reddit page.</p>
  
  <p>How would one model the reducer around that? I was thinking of having the reducer be a map -> id of the comments where you can filter by page using the <code>pageId</code>.</p>
  
  <p>The issue is that for example when we want to add a comment to a nested one: we need to create the record on the root of the map and then add its id in the parent children property. To display all the comments we'd need to get all of them, filter those that we have at the top (that would be kept in the page reducers as an orderedList for example) and then iterate on them, fetching from the comments objects when we encounter children using recursion.</p>
  
  <p>Is there a better approach than that or is it flawed?</p>