I want to turn this
Here's one way you could look at it:
XSLT 1.0
Do a search for sibling recursion for an alternative method.