add non-recursion for tree traverse