code: public static function getLast(Iterator $iterator, $defaultValue = null)
      {
          $last = $defaultValue;
          Iterators::each($iterator, function ($element) use (&$last) {
              $last = $element;
          });
          return $last;
      }
docs: Returns the last element provided by $iterator. If the iterator is not valid, returns $defaultValue.
  
  @param Iterator $iterator
  @param null $defaultValue
  @return mixed|null