use iterative traversal