Get all selected Parent + Child nodes?

I have a 2 level tree and want a string formatted by parent node followed by all its children, then the next parent node and all its children and so on. Is there a simple built in way to do this? Please point me in the right direction

many thanks

You can use tree.getSubItems(0) to get list of top items. After that you can call getSubItems for each top level id - to get list of related child items.