Implement filter and filterWithKey.