You haven't made it clear quite how flexible the input structure is, or what kind of output you want. I would personally be very inclined to start by transforming this to a more straightforward XML representation:
and then everything would start to seem much simpler.
However, whatever the output you're aiming for, recursive structures are best dealt with by a stylesheet that does recursive descent using apply-templates. Just write a rule for each kind of element, and in that rule do what you need to do with that element, then call apply-templates to process its children. I can't tell you what these rules should look like (or even how many there should be - it's not clear whether attributes at different levels are processed the same way) without knowing your desired output.
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference