void (TreeExpansionEvent event) { DefaultMutableTreeNode expandedNode = (DefaultMutableTreeNode)event.getPath().getLastPathComponent(); for (int i = 0; i < expandedNode.getChildCount(); i++) { DefaultMutableTreeNode child = (DefaultMutableTreeNode)expandedNode.getChildAt(i); if (child.getChildCount() == 0 && !isLooped(event.getPath(), child)) { Module module = ((MyUserObject)child.getUserObject()).myModule; for (Module dependency : getModuleDependencies(module)) { child.add(new DefaultMutableTreeNode(new MyUserObject(isInCycle(dependency), dependency))); } TreeUtil.sortRecursively(child, NODE_COMPARATOR); } } }