I think I solved it a while ago:
P.S. Oh wait, you want to do this from a hierarchy table. Gimme a minute. P.P.S. Here you go, lol: