I actually wrote a java function that did this a couple of years ago, in school, as an excersise in "binary trees". I lost it, and most of my programming knowledge, but I figured perhaps there is a way to do this easily in python? It seems to me like it could be a common problem.
/Arvid Andersson -- http://mail.python.org/mailman/listinfo/python-list