I think something like this would help:
var ignoreEvents = false;
function nodeEventHandler(treeview, node, eventType)
{
if (ignoreEvents) return;
ignoreEvents = true;
if (eventType == \"collapsed\") {
node.clearChildNodes();
node.setPopulateNodesOnDemand(true);
}
ignoreEvents = false;
}
Do not forget to set: