Using your coding style, my solution looks like:

rs = getTreeTraversal()
displayTree(rs, displayFunction)

function displayFunction(item) {
. . doSomething_1
}

Which one is easier to implement depends on the details of walking the tree*. The more state that must be kept between touching each node, the easier it is to implement it my way, although that is not the only consideration. (BTW, tree traversal need only look trivial for the code using the tree.)

Actually, implementing this with a closure makes it look like your example, but it works more like mine: you get the advantage of a loop-like construct in both places.

Wade.

* although I've let it slide 'till now, whether or not the tree is database-backed or just in-memory is not important in my example.