private static void writeNodeToBuffer(StringBuilder builder, SyntaxNode node, int indentation)
    {
        builder.append("[").append(node.type.name());
        if (node.children == null) {
            String simpleText = node.getSimpleText();
            if (simpleText != null) {
                builder.append(" \"").append(simpleText).append('"');
            }
        } else {
            if (node.type == NodeType.BLOCK && ((BlockNode)node).argumentDeclarations != null) {
                builder.append("\n");
                for (int i = 0; i < indentation + 1; i++)
                    builder.append("  ");
                SyntaxNode argumentDeclarations = ((BlockNode)node).argumentDeclarations;
                writeNodeToBuffer(builder, argumentDeclarations, indentation + 1);
            }
            for (SyntaxNode child : node.children) {
                builder.append("\n");
                for (int i = 0; i < indentation + 1; i++)
                    builder.append("  ");
                writeNodeToBuffer(builder, child, indentation + 1);
            }
            if (node.children.length > 0) {
                builder.append("\n");
                for (int i = 0; i < indentation; i++)
                    builder.append("  ");
            }
        }
        builder.append("]");
    }