code: protected List<? extends ItemData> mergeList(ItemData rootData, DataManager dataManager, boolean deep, int action)
        throws RepositoryException
     {
  
        // 1 get all transient descendants
        List<ItemState> transientDescendants = new ArrayList<ItemState>();
        traverseTransientDescendants(rootData, action, transientDescendants);
  
        if (deep || !transientDescendants.isEmpty())
        {
           // 2 get ALL persisted descendants
           Map<String, ItemData> descendants = new LinkedHashMap<String, ItemData>();
           traverseStoredDescendants(rootData, dataManager, action, descendants, true, transientDescendants);
  
           // merge data
           for (ItemState state : transientDescendants)
           {
              ItemData data = state.getData();
              if (!state.isDeleted())
              {
                 descendants.put(data.getIdentifier(), data);
              }
              else
              {
                 descendants.remove(data.getIdentifier());
              }
           }
           Collection<ItemData> desc = descendants.values();
           List<ItemData> retval;
           if (deep)
           {
              int size = desc.size();
              retval = new ArrayList<ItemData>(size < 10 ? 10 : size);
  
              for (ItemData itemData : desc)
              {
                 retval.add(itemData);
                 if (deep && itemData.isNode())
                 {
                    retval.addAll(mergeList(itemData, dataManager, true, action));
                 }
              }
           }
           else
           {
              retval = new ArrayList<ItemData>(desc);
           }
           return retval;
        }
        else
        {
           return getStoredDescendants(rootData, dataManager, action);
        }
     }
docs: Merge a list of nodes and properties of root data. NOTE. Properties in the list will have empty
  value data. I.e. for operations not changes properties content. USED FOR DELETE.
  
  @param rootData
  @param dataManager
  @param deep
  @param action
  @return
  @throws RepositoryException