visit tree by layer