void () { final Set<Sdk> jdks = new HashSet<>(); for(int i = 0; i < myRoot.getChildCount(); i++){ final DefaultMutableTreeNode node = (DefaultMutableTreeNode)myRoot.getChildAt(i); final NamedConfigurable<?> namedConfigurable = (NamedConfigurable<?>)node.getUserObject(); jdks.add(((JdkConfigurable)namedConfigurable).getEditableObject()); } final HashMap<Sdk, Sdk> sdks = new HashMap<>(myProjectJdksModel.getProjectSdks()); for (Sdk sdk : sdks.values()) { if (!jdks.contains(sdk)) { myProjectJdksModel.removeSdk(sdk); } } }