Lazy loading (worth mentioning)

Even if there are 100s of main folders, the child sqls are expanded only if the UI opens up that folder and requests for that data.

Caveats

Obviously this may not be ideal way to construct data if your intention is to retrieve all or most of folders and their children all the time. In that case one can write a special handler which will do a table join and then break it up into a tree to save on the multiple sqls that get fired back.