most likely the problem is that you do not use the node_id, but the node itself as parameter for the fetch function for subnodeslist.
Apart from that I would use the foreach statement instead of section loop. You need less code and IMO it is much clearer which variable holds which information. So the relevant part of your code would look like ( this is not tested...):
One last thing: When posting here please surround your code examples with code tags (you can see an example on the righthand side when you write a post). This makes it much easier to tell the code apart from the question.