public static <T> Optional<T> firstMatching(T[] array, Predicate<? super T> predicate) {
        for (T t: array) {
            if (predicate.test(t))
                return Optional.of(t);
        }
        return Optional.empty();
    }
Returns the first element in a collection according to iteration order.
Returns null if the collection is empty.
vespajlib/src/main/java/com/yahoo/collections/CollectionUtil.java