adding a treelist iterator to clean up traversal code.