This should be implemented as a RecursiveFilterIterator, to apply it before the RecursiveIteratorIterator instead of iterating over the whole filesystem first and then filtering. A prefix-based filter is the perfect fit for filtering before flattening the traversal