public static @Nullable IndexedRelevantResource<String, XsdNamespaceBuilder> guessSchema(String namespace,
                                                                                           final @Nullable String tagName,
                                                                                           final @Nullable String version,
                                                                                           @Nullable String schemaLocation,
                                                                                           @Nullable Module module,
                                                                                           @NotNull Project project) {

    final List<IndexedRelevantResource<String, XsdNamespaceBuilder>>
      resources = getResourcesByNamespace(namespace, project, module);

    if (resources.isEmpty()) return null;
    if (resources.size() == 1) return resources.get(0);
    final String fileName = schemaLocation == null ? null : new File(schemaLocation).getName();
    IndexedRelevantResource<String, XsdNamespaceBuilder> resource =
      Collections.max(resources, (o1, o2) -> {
        if (fileName != null) {
          int i = Boolean.compare(fileName.equals(o1.getFile().getName()), fileName.equals(o2.getFile().getName()));
          if (i != 0) return i;
        }
        if (tagName != null) {
          int i = Boolean.compare(o1.getValue().hasTag(tagName), o2.getValue().hasTag(tagName));
          if (i != 0) return i;
        }
        int i = o1.compareTo(o2);
        if (i != 0) return i;
        return o1.getValue().getRating(tagName, version) - o2.getValue().getRating(tagName, version);
      });
    if (tagName != null && !resource.getValue().hasTag(tagName)) {
      return null;
    }
    return resource;
  }
public static @Nullable IndexedRelevantResource<String, XsdNamespaceBuilder> guessSchema(String namespace,
                                                                                           final @Nullable String tagName,
                                                                                           final @Nullable String version,
                                                                                           @Nullable String schemaLocation,
                                                                                           @Nullable Module module,
                                                                                           @NotNull Project project)