private void mergeStageTree(VersionedRepo rp, String cRef, Map.Entry<String, String> t) {
   // They are different, we need to merge them
   StageTree st =
       new StageTree(rp.getObjectDatabase().getTree(shadow.getTrees().get(t.getKey())), capacity);
   st.apply(rp, rp.getObjectDatabase().getTree(t.getValue()), cRef);
   stagedTrees.put(t.getKey(), st);
 }
  public boolean removeFromStage(VersionedRepo rp, LinkedList<String> parts) {
    // Find the staged tree associated with this part and remove the
    // document reference from it

    String currentLevel = parts.remove();
    boolean removed = false;

    if (!parts.isEmpty()) {
      if (stagedTrees.containsKey(currentLevel)) {
        stagedTrees.get(currentLevel).removeFromStage(rp, parts);
      } else if (shadow.getTrees().containsKey(currentLevel)) {
        TreeObject to = rp.getObjectDatabase().getTree(shadow.getTrees().get(currentLevel));
        StageTree newStage = new StageTree(to, capacity);
        stagedTrees.put(currentLevel, newStage);
        removed = newStage.removeFromStage(rp, parts);
      }
    } else {
      removedDocuments.add(currentLevel);
      removed = true;
    }
    return removed;
  }