If the relational system supports tree operations, then it is as simple as:
----Usage 1:
rs = getTreeTraversal()
while (getNext()) {
. . doSomething_1
}
----Usage 2:
rs = getTreeTraversal()
while (getNext()) {
. . doSomething_2
}
----Usage 3:
rs = getTreeTraversal()
while (getNext()) {
. . doSomething_3
}
The problem you are having is that the bread is more complex than the meat of the sandwich. Simplify the bread (tree traversal), and using tricky closure meat is no longer so important.
In practice, we probably want different filtering, cross referencing, etc. for each usage. That is where custom relational queries would shine. One-size-fits-all traversal is not that likely if there are many usages.