src/precore/util/Iterators.php
public static function find(Iterator $iterator, callable $predicate, $defaultValue = null)
    {
        $result = $defaultValue;
        while ($iterator->valid()) {
            $current = $iterator->current();
            if (Predicates::call($predicate, $current)) {
                $result = $current;
                break;
            }
            $iterator->next();
        }
        return $result;
    }
public static function find(Iterator $iterator, callable $predicate, $defaultValue = null)
    {
        $result = $defaultValue;
        while ($iterator->valid()) {
            $current = $iterator->current();
            if (Predicates::call($predicate, $current)) {
                $result = $current;
                break;
            }
            $iterator->next();
        }
        return $result;
    }
Returns the first element in iterator that satisfies the given predicate. If there is no such an element,
it returns $defaultValue.

@param Iterator $iterator
@param callable $predicate
@param null $defaultValue
@return mixed