@Toxaris
"... involves logic which might not be there"
You are right. I should specify my suggestion more precisely:
The pattern should be used, when the complete TOC is based on Hn and when it is "well formed" - no gaps in the heading structure, no inconsistent order of levels.
These editors get a smart pattern. The others not