public static function getNext(Iterator $iterator, $defaultValue = null)
    {
        $result = $defaultValue;
        if ($iterator->valid()) {
            $result = $iterator->current();
            $iterator->next();
        }
        return $result;
    }
public static function getNext(Iterator $iterator, $defaultValue = null)
    {
        $result = $defaultValue;
        if ($iterator->valid()) {
            $result = $iterator->current();
            $iterator->next();
        }
        return $result;
    }
Returns the current element of the iterator if it's valid and calls {@link Iterator::next} on it.
If the iterator is not valid, it returns $defaultValue.

@param Iterator $iterator
@param null $defaultValue
@return mixed|null