void () { DefaultMutableTreeNode selection = null; final TreePath selectionPath = myTree.getSelectionPath(); if (selectionPath != null) { selection = (DefaultMutableTreeNode)selectionPath.getLastPathComponent(); } createGroupingHelper(node -> true).moveAllModuleNodesToProperGroups(myRoot, getTreeModel()); if (selection != null) { TreeUtil.selectInTree(selection, true, myTree); } }