Utility code for creating filter function based on paths