Thank you very much nathand, this is just what I was looking for. The goal is to use a directed graph as "flow" in the direction from the leaf to the root does not to be considered. I will take a look and see what I can do efficiency wise. I owe you a beer!