-
- int iter = nodes [currentNode].FirstChild;
- int depth = nodes [currentNode].Depth;
- while (iter < nodes.Length && nodes [iter].Depth > depth) {
+
+ int end = nodes [currentNode].NextSibling;
+ if (end == 0) {
+ int tmp = currentNode;
+ do {
+ tmp = nodes [tmp].Parent;
+ end = nodes [tmp].NextSibling;
+ } while (end == 0 && tmp != 0);
+ if (end == 0)
+ end = nodes.Length;
+ }
+
+ while (iter < end) {