flattenTree