Flatten tree recusive