Additional section header nesting logic.

This remains incomplete but now deals with some extra scenarios.

Where the next size is equal to the size before, this is now correctly handed and nested as a sibling (equal depth).

When the last heading is encountered, this is now correctly nested along with all remaining siblings.

When a smaller heading is encountered, this is partially handled. The next step is to create a more comprehensive test document that exercises all of the permutations so that we can accurately test this (and so that I can more thoroughly check that I've got the logic right).