adding more sanity checks to tree traverse