final implementation for dynamic hierarchical filter