Fix keepif

Thanks @johnno1962 for pointing out the bug.

I couldn't merge the PR since the branch was already deleted.
The current implementation uses `NSPredicate` instead of manual iteration.