private PsiElement @NotNull [] getElementsToDelete(@NotNull Project project, @NotNull DataContext dataContext) {
    PsiElement[] elements = getSelectedPSIElements(dataContext);
    for (int idx = 0; idx < elements.length; idx++) {
      final PsiElement element = elements[idx];
      if (element instanceof PsiDirectory directory) {
        final ProjectViewDirectoryHelper directoryHelper = ProjectViewDirectoryHelper.getInstance(project);
        if (hideEmptyMiddlePackages(dataContext) &&
            directory.getChildren().length == 0 &&
            !directoryHelper.skipDirectory(directory)) {
          while (true) {
            PsiDirectory parent = directory.getParentDirectory();
            if (parent == null) break;
            if (directoryHelper.skipDirectory(parent) ||
                PsiDirectoryFactory.getInstance(project).getQualifiedName(parent, false).isEmpty()) {
              break;
            }
            PsiElement[] children = parent.getChildren();
            if (children.length == 0 || children.length == 1 && children[0] == directory) {
              directory = parent;
            }
            else {
              break;
            }
          }
          elements[idx] = directory;
        }
        final VirtualFile virtualFile = directory.getVirtualFile();
        final String path = virtualFile.getPath();
        if (path.endsWith(JarFileSystem.JAR_SEPARATOR)) { // if is jar-file root
          final VirtualFile vFile =
            LocalFileSystem.getInstance().findFileByPath(path.substring(0, path.length() - JarFileSystem.JAR_SEPARATOR.length()));
          if (vFile != null) {
            final PsiFile psiFile = PsiManager.getInstance(project).findFile(vFile);
            if (psiFile != null) {
              elements[idx] = psiFile;
            }
          }
        }
      }
    }
    return elements;
  }
private PsiElement @NotNull [] getElementsToDelete(@NotNull Project project, @NotNull DataContext dataContext)