Tree flatten