flat to tree