Matching folders by pathname

Is it possible to match a folder on the basis of its path? For instance, say I want to match all folders contained at any depth by some folder named `foo`. Is this possible? The condition "File pathname" can accomplish this (by matching on `/foo/`), however it seems to apply to files only, and I'm looking for something that works for both files and folders.