private void encode(StringBuilder ret) {
        if (note != null) {
            ret.append("[");
            for (int i = 0, len = note.length(); i < len; ++i) {
                char c = note.charAt(i);
                if (c == '\\' || c == ']') {
                    ret.append('\\');
                }
                ret.append(note.charAt(i));
            }
            ret.append("]");
        } else {
            ret.append(strict ? "(" : "{");
            for (TraceNode child : children) {
                child.encode(ret);
            }
            ret.append(strict ? ")" : "}");
        }
    }
Writes a parseable string representation of this trace node to the given string builder.

@param ret The string builder to write to.
messagebus/src/main/java/com/yahoo/messagebus/TraceNode.java