@Override
    public ObjectNode toNode() {
        //constructing shapes ObjectNode map
        ObjectNode.Builder shapesBuilder = ObjectNode.objectNodeBuilder();
        for (Map.Entry<ShapeId, List<ShapeLink>> entry : shapes.entrySet()) {
            String shapeId = entry.getKey().toString();
            ArrayNode shapeListNode = entry.getValue() //get list of ShapeLinks
                    .stream()
                    .map(ShapeLink::toNode) //convert each ShapeLink to an ObjectNode
                    .collect(ArrayNode.collect()); //collect each ObjectNode in an ArrayNode
            shapesBuilder.withMember(shapeId, shapeListNode);
        }

        //returning ObjectNode for TraceFile
        return ObjectNode.objectNodeBuilder()
                .withMember(SMITHY_TRACE_TEXT, smithyTrace)
                .withMember(METADATA_TEXT, metadata)
                .withOptionalMember(DEFINITIONS_TEXT, getArtifactDefinitions())
                .withMember(SHAPES_TEXT, shapesBuilder.build())
                .build();
    }
Converts TraceFile instance variables into an
ObjectNode.

@return ObjectNode representation of a TraceFile.
smithy-codegen-core/src/main/java/software/amazon/smithy/codegen/core/trace/TraceFile.java