@NotNull
 private DefaultMutableTreeNode addPackage(PsiPackage aPackage) {
   final String qualifiedPackageName = aPackage.getQualifiedName();
   final PsiPackage parentPackage = aPackage.getParentPackage();
   if (parentPackage == null) {
     final DefaultMutableTreeNode rootNode = (DefaultMutableTreeNode) myModel.getRoot();
     if (qualifiedPackageName.length() == 0) {
       rootNode.setUserObject(aPackage);
       return rootNode;
     } else {
       DefaultMutableTreeNode packageNode = findPackageNode(rootNode, qualifiedPackageName);
       if (packageNode != null) return packageNode;
       packageNode = new DefaultMutableTreeNode(aPackage);
       rootNode.add(packageNode);
       return packageNode;
     }
   } else {
     final DefaultMutableTreeNode parentNode = addPackage(parentPackage);
     DefaultMutableTreeNode packageNode = findPackageNode(parentNode, qualifiedPackageName);
     if (packageNode != null) {
       return packageNode;
     }
     packageNode = new DefaultMutableTreeNode(aPackage);
     parentNode.add(packageNode);
     return packageNode;
   }
 }
 @Nullable
 private static DefaultMutableTreeNode findPackageNode(
     DefaultMutableTreeNode rootNode, String qualifiedName) {
   for (int i = 0; i < rootNode.getChildCount(); i++) {
     final DefaultMutableTreeNode child = (DefaultMutableTreeNode) rootNode.getChildAt(i);
     final PsiPackage nodePackage = (PsiPackage) child.getUserObject();
     if (nodePackage != null) {
       if (Comparing.equal(nodePackage.getQualifiedName(), qualifiedName)) return child;
     }
   }
   return null;
 }
 private DefaultMutableTreeNode findNodeForPackage(String qualifiedPackageName) {
   DefaultMutableTreeNode root = (DefaultMutableTreeNode) myModel.getRoot();
   Enumeration enumeration = root.depthFirstEnumeration();
   while (enumeration.hasMoreElements()) {
     Object o = enumeration.nextElement();
     if (o instanceof DefaultMutableTreeNode) {
       DefaultMutableTreeNode node = (DefaultMutableTreeNode) o;
       PsiPackage nodePackage = (PsiPackage) node.getUserObject();
       if (nodePackage != null) {
         if (Comparing.equal(nodePackage.getQualifiedName(), qualifiedPackageName)) return node;
       }
     }
   }
   return null;
 }