fix recursive prefix in __flatten_patterns_tree