refine text
introduce leaf depth to control the level to go down