title: Trying to flatten objects in reducer
body: <p>Similar to this question <a href="https://stackoverflow.com/questions/34401098/remove-a-property-in-an-object-immutably">Remove a property in an object immutably</a></p>
  <p>I have an object</p>
  <pre><code>  parent {
       child {
         grandchild {},
       },
    },
  </code></pre>
  <p>I'm trying to flatten in a reducer</p>
  <pre><code>   parent: {}
     child:  {}
     grandchild: {}
  </code></pre>
  <p>With a merge function that breaks the objects up based on some requirements.</p>
  <pre><code>merge(state, object){
  
    ....
    if(parent.child) mergeAndDelete(state, parent.child, parent, 'child')
  
  }
  
  
  function mergeAndDelete(state, type, id, ent, attrib) {
    const clone = cloneDeep(ent[attrib]);
    merge(state, type, id, clone);
    delete ent[attrib];
  }
  </code></pre>
  <p>If I delete the entity, even after the merge then the child and grandchild never make it to the reducer. They console log the whole way through. If I don't delete then they get merged as I want. But parent still has child etc.</p>
  <p>What is the best way of going about this?</p>