Add filter and filterAll methods

Improve API to filter keys based on a predicate.