Replaces
collection.collect(f).headOption
with
collection.collectFirst(f)
if possible.