I'm not sure why you say "that doesn't scale very nicely". Doing the moral equivalent of building the HoH is going to be necessary to do anything tree-like with that data structure.
It's fairly trivial, anyway; but you've not said what the
difference between id and name is...which is foo,bar,troz,narf in your example, and what is the other?