It would have been nice to use rowgrouping for the node name, but somehow it wasn't easy to get the rowcount. So this should do for now.