guava/src/com/google/common/collect/Iterators.java
public static <T> @Nullable T getLast(Iterator<? extends T> iterator, @Nullable T defaultValue) {
    return iterator.hasNext() ? getLast(iterator) : defaultValue;
  }
public static <T> @Nullable T getLast(Iterator<? extends T> iterator, @Nullable T defaultValue) {
    return iterator.hasNext() ? getLast(iterator) : defaultValue;
  }
Advances {@code iterator} to the end, returning the last element or {@code defaultValue} if the
iterator is empty.

@param defaultValue the default value to return if the iterator is empty
@return the last element of {@code iterator}
@since 3.0