It’s probably easiest to split the layer at the loop beginning, remove extraneous keyframes before then, and then use your loopOut expression.
There’s a little-known option with loopOut() to specific the number of keyframes back from the last one to use for the loop. There’s another variation on loopOut called loopOutDuration() that allows you to specific the time back from the last keyframe for the looping section. Both of these are covered in the expression language reference [link].
It would be possible to write an expression that does what you describe, but you’d have to re-write the loopOut functionality from scratch, using valueAtTime().
Walter Soyka
Designer & Mad Scientist at Keen Live [link]
Motion Graphics, Widescreen Events, Presentation Design, and Consulting
@keenlive | RenderBreak [blog] | Profile [LinkedIn]