}
public void serialize(MetricTreeBase tree, OutputStream os) throws IOException {
final JsonGenerator jsonGenerator = jsonFactory.createJsonGenerator(os);
tree.accept(new MetricTreeVisitor() {
private void writeKey(MetricTreeBase o) throws JsonGenerationException, IOException {
if (o.getKey() != null) {
jsonGenerator.writeFieldName(o.getKey());
}
}