code: public static <T> Optional<T> findOptionalAmongst(Class<T> clazz, Collection<?> instances) {
      return findStreamAmongst(clazz, instances)
        .reduce((i1, i2) -> {
          throw new IllegalArgumentException("More than one " + clazz.getName() + " found");
        });
    }
docs: Find the only expected instance of {@code clazz} among the {@code instances}.
  
  @param clazz searched class
  @param instances instances looked at
  @param <T> type of the searched instance
  @return the optionally found compatible instance
  @throws IllegalArgumentException if more than one matching instance