Simplified search using foldr (mappend . f) mempty