Replaces seq(seq.size - 1) or seq.apply(seq.size - 1) to seq.last if seq is not an instance of IndexedSeq.