Use a Queue in tree_equals().

Also rewrite a weird for loop form. Must've been a leftover.