Added function for nonrecursive evaluation of a tree