Expand selected branches with multiple loadXML

I have a tree with dynamicLoading enabled.
I hava list of nodes to expand and need to expand them one after another, because they are on level0,level1,…,levelN.
I hava a loop

for (j=0;j<pathArr.length;j++)

array content is:
Sometimes it works fine, but other times the requests (at least in access.log) are NOT in the order the array is.

My question is:
How to load tree with many calls of loadXML() and force each call to wait for the previous one to complete. Or is thera another way to expand a few branches with dynamicLoading?


This feature is available for ‘pro’ version users only I think.
First option is loop that checks getXMLState():

function wait() { document.getElementById("progress").innerHTML+=number; number++; if(tree.getXMLState() == true) { timer = setTimeout('wait()',1000); } }
before loading next branch of tree.
But it did not work as I expected.
Happily I found openItemsDynamic() function, which solves the problem and loads many branches one after another.