private void restoreExpansionStatus(InspectionTreeNode node) {
   if (myExpandedUserObjects.contains(node.getUserObject())) {
     sortChildren(node);
     TreeNode[] pathToNode = node.getPath();
     expandPath(new TreePath(pathToNode));
     Enumeration children = node.children();
     while (children.hasMoreElements()) {
       InspectionTreeNode childNode = (InspectionTreeNode) children.nextElement();
       restoreExpansionStatus(childNode);
     }
   }
 }
 @Override
 public void treeWillExpand(TreeExpansionEvent event) throws ExpandVetoException {
   final InspectionTreeNode node = (InspectionTreeNode) event.getPath().getLastPathComponent();
   final Object userObject = node.getUserObject();
   // TODO: never re-sort
   if (node.isValid() && !myExpandedUserObjects.contains(userObject)) {
     sortChildren(node);
     nodeStructureChanged(node);
   }
   myExpandedUserObjects.add(userObject);
   // Smart expand
   if (node.getChildCount() == 1) {
     ApplicationManager.getApplication()
         .invokeLater(
             new Runnable() {
               @Override
               public void run() {
                 expandPath(new TreePath(node.getPath()));
               }
             });
   }
 }
 @Override
 public void treeWillCollapse(TreeExpansionEvent event) throws ExpandVetoException {
   InspectionTreeNode node = (InspectionTreeNode) event.getPath().getLastPathComponent();
   myExpandedUserObjects.remove(node.getUserObject());
 }