private static Map<ShapeId, Pair<Trait, Trait>> findTraitDifferences(Shape oldShape, Shape newShape) {
        Map<ShapeId, Pair<Trait, Trait>> changes = new HashMap<>();
        for (Trait oldTrait : oldShape.getAllTraits().values()) {
            Trait newTrait = newShape.findTrait(oldTrait.toShapeId()).orElse(null);
            if (newTrait == null) {
                changes.put(oldTrait.toShapeId(), (Pair.of(oldTrait, null)));
            } else if (!newTrait.equals(oldTrait)) {
                changes.put(newTrait.toShapeId(), Pair.of(oldTrait, newTrait));
            }
        }
        // Find traits that were added.
        newShape.getAllTraits()
                .values()
                .stream()
                .filter(newTrait -> !oldShape.findTrait(newTrait.toShapeId()).isPresent())
                .forEach(newTrait -> changes.put(newTrait.toShapeId(), Pair.of(null, newTrait)));

        return changes;
    }
Finds the trait differences between the old and new shape.

@param oldShape Old shape.
@param newShape New shape.
@return Returns a map of each changed trait ID to a pair of the old and new trait values.
smithy-diff/src/main/java/software/amazon/smithy/diff/ChangedShape.java