What makes your posting unclear to me is that you *describe* that you want to use the result of getqueryresult() for calling processchild(), but this is not reflected in the code example you gave.

Also, you did not mention whether the interface of getqueryresult() is already fixed, or whether you are free to change it.

Basically, you could either have getqueryresult return a list of all childs and then iterate over the list, or you can write getqueryresult in a way that it accepts a code block, which it invokes for every child. I would do the latter if the number of childs is possibly large (and you don't need to store them anyway), and the former approach if the number of childs is small (less than 1000 or so, depending on how much data is associated with each child).