private static @Nullable VirtualFile getValidFile(FileElement element) {
    if (element == null) return null;
    final VirtualFile file = element.getFile();
    return file != null && file.isValid() ? file : null;
  }
private static @Nullable VirtualFile getValidFile(FileElement element)