How do I iterate over branches and sub-branches in a tree with python?

I think you might need to use the tree helper functions. This might help?