public static void correctRuleIndices(Node<?> node, int n) {
        if (n == 0)
            return;

        for (;;) {
            if (node instanceof CallNode) {
                ((CallNode) node).ruleIndex += n;
            } else if (node instanceof RuleNode) {
                ((RuleNode) node).index += n;
            }

            if (node instanceof UnaryNode) {
                node = ((UnaryNode) node).sibling;
            } else if (node instanceof BinaryNode) {
                BinaryNode x = (BinaryNode) node;
                correctRuleIndices(x.firstSibling, n);

                node = x.secondSibling;
            } else {
                return;
            }
        }
    }