void createTreeModel() {
    List<PackageUpdate> pkgUpdates = ActionUtil.underModalProgress(
      myProject,
      JavaBundle.message("package.chooser.modal.progress.title"
      ), () -> {
        PsiManager psiManager = PsiManager.getInstance(myProject);
        FileIndex fileIndex = myModule != null
                              ? ModuleRootManager.getInstance(myModule).getFileIndex()
                              : ProjectRootManager.getInstance(myProject).getFileIndex();
        List<PackageUpdate> pkgUpdateList = new ArrayList<>();
        fileIndex.iterateContent(fileOrDir -> {
          if (fileOrDir.isDirectory() && fileIndex.isUnderSourceRootOfType(fileOrDir, JavaModuleSourceRootTypes.SOURCES)) {
            PsiDirectory psiDirectory = psiManager.findDirectory(fileOrDir);
            ProgressManager.checkCanceled();
            LOG.assertTrue(psiDirectory != null);
            PsiPackage pkg = JavaDirectoryService.getInstance().getPackage(psiDirectory);
            if (pkg != null) pkgUpdateList.add(new PackageUpdate(pkg));
          }
          return true;
        });
        return pkgUpdateList;
      });
    for (PackageUpdate pkgUpdate : pkgUpdates) addPackage(pkgUpdate);
    TreeUtil.sort(myModel, (o1, o2) -> {
      PsiNamedElement element1 = (PsiNamedElement)((DefaultMutableTreeNode)o1).getUserObject();
      PsiNamedElement element2 = (PsiNamedElement)((DefaultMutableTreeNode)o2).getUserObject();
      return Objects.requireNonNull(element1.getName()).compareToIgnoreCase(Objects.requireNonNull(element2.getName()));
    });
  }
void createTreeModel()