private void advance() {

        if (current.getChildren().isEmpty()) {
            boolean foundNext = false;

            while (!foundNext) {

                currentLevel--;

                // check for global finish
                if (currentLevel == -1) {
                    return;
                }

                int idx = childPosForLevels.get(currentLevel);
                current = currentOfLevels.get(currentLevel);

                int maxChildren;

                if (onlyValids) {
                    maxChildren = current.getValidChildren().size();
                } else {
                    maxChildren = current.getChildren().size();
                }

                if (idx < (maxChildren - 1)) { // either to next sibling of current
                    idx++;
                    childPosForLevels.set(currentLevel, idx);
                    currentLevel++;

                    if (onlyValids) {
                        current = current.getValidChildren().get(idx);
                    } else {
                        current = current.getChildren().get(idx);
                    }

                    foundNext = true; // and out ====>
                } else { // or upward with next iteration

                    // delete entries of this level beforehand
                    childPosForLevels.remove(currentLevel);
                    currentOfLevels.remove(currentLevel);
                }
            } // end while

        } else {

            // or downward
            int childIdx = 0;
            childPosForLevels.add(currentLevel, childIdx); // first child in next level
            currentOfLevels.add(currentLevel, current);
            currentLevel++;

            if (onlyValids) {
                current = current.getValidChildren().get(childIdx);
            } else {
                current = current.getChildren().get(childIdx);
            }
        } // end if-else
    }