Filtering HierarchicalDataProvider

Is there some sort of generic approach in filtering a HierarchicalDataProvider that ensures you also have a path to the root node for the match (apart from rebuilding the e.g. TreeData)?