Create flatten tree