@RequiresBackgroundThread(generateAssertion = false)
  protected PsiDirectory @NotNull [] getSelectedDirectories(Object @NotNull[] selectedUserObjects) {
    List<PsiDirectory> directories = new ArrayList<>();
    for (Object obj : selectedUserObjects) {
      PsiDirectoryNode node = ObjectUtils.tryCast(obj, PsiDirectoryNode.class);
      if (node != null) {
        PsiDirectory directory = node.getValue();
        if (directory != null) {
          directories.add(directory);
          Object parentValue = node.getParent().getValue();
          if (parentValue instanceof PsiDirectory && Registry.is("projectView.choose.directory.on.compacted.middle.packages")) {
            while (true) {
              directory = directory.getParentDirectory();
              if (directory == null || directory.equals(parentValue)) {
                break;
              }
              directories.add(directory);
            }
          }
        }
      }
    }
    if (!directories.isEmpty()) {
      return directories.toArray(PsiDirectory.EMPTY_ARRAY);
    }

    List<PsiElement> elements = new ArrayList<>(selectedUserObjects.length);
    for (Object node : selectedUserObjects) {
      elements.addAll(getElementsFromNode(node));
    }

    if (elements.size() == 1) {
      final PsiElement element = elements.get(0);
      if (element instanceof PsiDirectory) {
        return new PsiDirectory[]{(PsiDirectory)element};
      }
      else if (element instanceof PsiDirectoryContainer) {
        return ((PsiDirectoryContainer)element).getDirectories();
      }
      else {
        final PsiFile containingFile = element.getContainingFile();
        if (containingFile != null) {
          final PsiDirectory psiDirectory = containingFile.getContainingDirectory();
          if (psiDirectory != null) {
            return new PsiDirectory[]{psiDirectory};
          }
          final VirtualFile file = containingFile.getVirtualFile();
          if (file instanceof VirtualFileWindow) {
            final VirtualFile delegate = ((VirtualFileWindow)file).getDelegate();
            final PsiFile delegatePsiFile = containingFile.getManager().findFile(delegate);
            if (delegatePsiFile != null && delegatePsiFile.getContainingDirectory() != null) {
              return new PsiDirectory[]{delegatePsiFile.getContainingDirectory()};
            }
          }
          return PsiDirectory.EMPTY_ARRAY;
        }
      }
    }
    else if (selectedUserObjects.length == 1) {
      return getSelectedDirectoriesInAmbiguousCase(selectedUserObjects[0]);
    }
    return PsiDirectory.EMPTY_ARRAY;
  }
@RequiresBackgroundThread(generateAssertion = false)
  protected PsiDirectory @NotNull [] getSelectedDirectories(Object @NotNull[] selectedUserObjects)