flattenTree.py recursive version 2