public static Predicate<Library> getNotAddedSuitableLibrariesCondition(final ModuleRootModel rootModel, final FacetsProvider facetsProvider) {
    final OrderEntry[] orderEntries = rootModel.getOrderEntries();
    final Set<Library> result = new HashSet<>(orderEntries.length);
    for (OrderEntry orderEntry : orderEntries) {
      if (orderEntry instanceof LibraryOrderEntry && orderEntry.isValid()) {
        final Library library = ((LibraryOrderEntry)orderEntry).getLibrary();
        if (library == null) continue;

        if (library instanceof LibraryEx) {
          final Library source = ((LibraryEx)library).getSource();
          result.add(source != null ? source : library);
        } else {
          result.add(library);
        }
      }
    }
    return library -> {
      if (result.contains(library)) return false;
      if (library instanceof LibraryEx) {
        final Library source = ((LibraryEx)library).getSource();
        if (source != null && result.contains(source)) return false;
      }
      if (library instanceof LibraryEx) {
        PersistentLibraryKind<?> kind = ((LibraryEx)library).getKind();
        if (kind != null) {
          LibraryType type = LibraryType.findByKind(kind);
          if (!type.isSuitableModule(rootModel.getModule(), facetsProvider)) {
            return false;
          }
        }
      }
      return true;
    };
  }
public static Predicate<Library> getNotAddedSuitableLibrariesCondition(final ModuleRootModel rootModel, final FacetsProvider facetsProvider)