Builds a nested heading tree from a flat, document-ordered sequence of headings.
Headings deeper than maxDepth are dropped entirely, along with
their descendants (never promoted to a shallower level). Each remaining heading
nests under the nearest preceding heading with a strictly shallower level; if none
exists — including when levels skip, e.g. an H3 with no preceding H1 or H2 — it
becomes a root entry.
public static IReadOnlyList<TocEntry> BuildTree(IReadOnlyList<(int Level, string Text, string Slug)> flatEntries, int maxDepth)