src/precore/util/Iterators.php
public static function contains(Iterator $iterator, $element) : bool
    {
        while ($iterator->valid()) {
            if (Objects::equal($iterator->current(), $element)) {
                return true;
            }
            $iterator->next();
        }
        return false;
    }
public static function contains(Iterator $iterator, $element) : bool
    {
        while ($iterator->valid()) {
            if (Objects::equal($iterator->current(), $element)) {
                return true;
            }
            $iterator->next();
        }
        return false;
    }
Returns true if iterator contains element. The check based on {@link Objects::equal()}.

@param Iterator $iterator
@param $element
@return boolean