void (@NotNull JTree tree, @NotNull Point treePoint) { final TreePath toRetain = tree.getPathForLocation(treePoint.x, treePoint.y); if (toRetain == null) return; TreePath[] selection = tree.getSelectionModel().getSelectionPaths(); selection = selection == null ? EMPTY_TREE_PATH : selection; for (TreePath each : selection) { if (toRetain.equals(each)) continue; tree.getSelectionModel().removeSelectionPath(each); } }