I've got the system filling root trees correctly now (I think). Still got a bit of work to do, but now I can start integrating it with the UI.