DefaultMutableTreeNode (String qualifiedPackageName) { DefaultMutableTreeNode root = (DefaultMutableTreeNode)myModel.getRoot(); Enumeration<TreeNode> enumeration = root.depthFirstEnumeration(); while (enumeration.hasMoreElements()) { if (enumeration.nextElement() instanceof DefaultMutableTreeNode node) { PsiPackage nodePackage = (PsiPackage)node.getUserObject(); if (nodePackage != null) { if (Objects.equals(nodePackage.getQualifiedName(), qualifiedPackageName)) return node; } } } return null; }