src/precore/util/Iterators.php
public static function getLast(Iterator $iterator, $defaultValue = null)
    {
        $last = $defaultValue;
        Iterators::each($iterator, function ($element) use (&$last) {
            $last = $element;
        });
        return $last;
    }
public static function getLast(Iterator $iterator, $defaultValue = null)
    {
        $last = $defaultValue;
        Iterators::each($iterator, function ($element) use (&$last) {
            $last = $element;
        });
        return $last;
    }
Returns the last element provided by $iterator. If the iterator is not valid, returns $defaultValue.

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