hast utility to get the rank (or depth, level) of headings
Limit the complexity of your GraphQL queries based on depth.
Get the Depth of a Multi-Dimensional Array of Values
remark-lint rule to warn when the first heading has a level other than a specified value