remove redundant test, use iterateNodes instead of recursion