private void updateTree(@Nullable CachingSimpleNode nodeToUpdate) {
    Set<CachingSimpleNode> toUpdate = new ReferenceOpenHashSet<>();
    if (nodeToUpdate == null) {
      for (DefaultMutableTreeNode node : myTree.getSelectedNodes(DefaultMutableTreeNode.class, null)) {
        final Object userObject = node.getUserObject();
        if (userObject instanceof SimpleNode && ((SimpleNode)userObject).getParent() instanceof CachingSimpleNode) {
          toUpdate.add((CachingSimpleNode)((SimpleNode)userObject).getParent());
        }
      }
    }
    else {
      toUpdate.add(nodeToUpdate);
    }

    if (toUpdate.isEmpty()) {
      toUpdate.add(myRootNode);
    }

    Element treeStateElement = new Element("root");
    try {
      TreeState.createOn(myTree).writeExternal(treeStateElement);
    }
    catch (WriteExternalException ignore) {
    }

    for (CachingSimpleNode node : toUpdate) {
      cleanUpEmptyNodes(node);
    }

    TreeState.createFrom(treeStateElement).applyTo(myTree);
  }
private void updateTree(@Nullable CachingSimpleNode nodeToUpdate)