private function getLast($func, $throw)
{
$source = $this->getWhereIteratorOrInnerIterator($func);
$count = 0;
$last = null;
foreach ($source as $stored) {
$count++;
$last = $stored;
}
if ($count == 0 && $throw) {
throw new \RuntimeException("The input sequence contains no matching element.");
}
return $last;
}