public static @Nullable VirtualFile asVirtualFile(@Nullable PsiElement element) {
    PsiFileSystemItem psiFile = null;
    if (element instanceof PsiFileSystemItem) {
      psiFile = (PsiFileSystemItem)element;
    }
    else if (element instanceof PsiDirectoryContainer) {
      PsiDirectory[] directories = ((PsiDirectoryContainer)element).getDirectories();
      if (directories.length == 0) {
        LOG.error("No directories for " + element + " of " + element.getClass());
        return null;
      }
      psiFile = directories[0];
    }
    else if (element != null) {
      psiFile = element.getContainingFile();
    }
    if (psiFile != null) {
      return psiFile.getVirtualFile();
    }
    return null;
  }
public static @Nullable VirtualFile asVirtualFile(@Nullable PsiElement element)