This isn't much tested, so don't trust it much, and I hope it's not overkill. You can find Graph here: http://sourceforge.net/projects/pynetwork/ With this you can plot the tree, if you want: g.springCoords(); g.plot2d()
Bear hugs, bearophile def scan(g, parent): subs = [scan(g, sub) for sub in g.outNodes(parent)] if subs: return [parent, subs] else: return parent from graph import Graph g = Graph() for d in source_list: g.addArc(d["parent"], d["title"]) roots = [n for n in g if not g.inNodes(n)] assert len(roots) == 1 # optional result = scan(g, roots[0])[1] print result, "\n\n", tree_result_list -- http://mail.python.org/mailman/listinfo/python-list