generic XSLT for deep level grouping/unwrapping

use case:
Say you want to convert html5 to dtbook. In html5
you can have an infinite amount of sectioning elements
(using the "section" element). In DTBook you only have
six levels, level1-level6 (unless you use the level
element, but not all tools support that). This XSLT
can be used as a preprocessing step to make sure
that no sectioning elements go deeper than six levels.

The XSLT is generic and should work with most XML grammars.

See the included xspec test for an example.

parameters:
 * element name (for which you want to prevent deep nesting)
 * element namespace
 * max allowed nesting depth before unwrapping takes place
 * whether or not to include wrapper elements (see code comments)