Our old application takes the Layer tree of a single map service and collects layers with no subLayerIds under a category node defined by the parents 'name'.
The internal map service is created from a public service mxd, with layer files dragged into the root of the map document. These layer files are in group layers named the same as the public ones, so when the code reads from the internal service it just merges the internal featureclass layers into the same group name as the public ones, to generate the layerlist.
Map service layers:
So this is what I'm trying to reproduce in a custom LayerList widget and I haven't a clue where to start, so any clues?