lastNotNullOrElse

inline fun <T> Iterable<T?>.lastNotNullOrElse(defaultValue: () -> T): T
inline fun <T> List<T?>.lastNotNullOrElse(defaultValue: () -> T): T

Returns the last element which is not null, or the result of calling the defaultValue function if there are no elements or all elements are null.