misc: Added flattenTree(tree)