Find the max element of a numeric vector iteratively with mask and early break

I think this issue is already addressed here.