private PsiElement @NotNull [] getSelectedElements() {
    VirtualFile[] selectedFiles = getSelectedFiles();
    Set<PsiElement> psiElements = new HashSet<>(selectedFiles.length);
    PsiManager psiManager = PsiManager.getInstance(thumbnailView.getProject());
    for (VirtualFile file : selectedFiles) {
      PsiFile psiFile = psiManager.findFile(file);
      PsiElement element = psiFile != null ? psiFile : psiManager.findDirectory(file);
      if (element != null) {
        psiElements.add(element);
      }
    }
    return PsiUtilCore.toPsiElementArray(psiElements);
  }
private PsiElement @NotNull [] getSelectedElements()