traverse tree by stack