Basic support for looping nested elements. Fragile, but a start.