code: public static <T> T singleOrNull(Collection<T> items, Predicate<T> predicate) {
          if (isEmpty(items)) {
              return null;
          }
  
          T result = null;
  
          for (T item : items) {
              if (predicate.apply(item)) {
                  if (result == null) {
                      result = item;
                  } else {
                      throw new InvalidOperationException("Multiple items match!");
                  }
              }
          }
  
          return result;
      }
docs: Returns the only element from a collection that matches the given predicate or null if such element is not found.
  Throws a {@link InvalidOperationException} if there is more than 1 element matching the predicate.
  
  @param items source items
  @param predicate predicate function
  @param <T> type of elements in the source collection
  @return the only element that matches the given predicate or null if such element is not found
  @throws InvalidOperationException if there is more than 1 element matching the predicate