Add implementation of method `filter`