return; }    ArrayList nodesToDelete = new ArrayList(); Enumeration nodes = node.breadthFirstEnumeration(); nodes.nextElement(); while (nodes.hasMoreElements()) { DefaultMutableTreeNode childNode = (DefaultMutableTreeNode)nodes.nextElement();  if (childNode.isLeaf()) nodesToDelete.add(childNode); }  for (int i = 0; i < nodesToDelete.size(); i++) { DefaultMutableTreeNode nodeToDelete = (DefaultMutableTreeNode)nodesToDelete.get(i); Object o = nodeToDelete.getUserObject(); if (o instanceof Experiment) deleteExperimentInNode(nodeToDelete); else if (o instanceof RecipeComponent) deleteRecipeInNode(nodeToDelete); else if (o instanceof String) model.removeNodeFromParent(nodeToDelete);  }     if (node.isLeaf()) model.removeNodeFromParent(node); else deleteEmptyFolders(node);
  public void deleteFolder() {    DefaultMutableTreeNode node = getSelectedNode();    if (node == root) return;    if (node == null) return;    int reply =       JOptionPane.showConfirmDialog(this,                                    "Delete folder and all its contents?",                                    "Delete Folder",                                    JOptionPane.OK_CANCEL_OPTION,                                    JOptionPane.PLAIN_MESSAGE);    if (reply == JOptionPane.OK_OPTION)      model.removeNodeFromParent(node);  }