private void extract(
                Map<String, Node> result,
                Shape currentShape,
                int segmentPosition,
                Node currentValue,
                String path
        ) {
            // Don't keep crawling when a "" segment is hit or the last segment is hit.
            if (segmentPosition >= segements.size() || segements.get(segmentPosition).isEmpty()) {
                result.put(path, currentValue);
                return;
            }

            String segment = segements.get(segmentPosition);
            currentShape.getMember(segment).flatMap(m -> model.getShape(m.getTarget())).ifPresent(nextShape -> {
                if (currentShape instanceof CollectionShape) {
                    currentValue.asArrayNode().ifPresent(v -> {
                        for (int i = 0; i < v.size(); i++) {
                            Node value = v.get(i).get();
                            extract(result, nextShape, segmentPosition + 1, value, path + "/" + i);
                        }
                    });
                } else if (currentShape instanceof MapShape) {
                    currentValue.asObjectNode().ifPresent(v -> {
                        for (Map.Entry<String, Node> entry : v.getStringMap().entrySet()) {
                            extract(result,
                                    nextShape,
                                    segmentPosition + 1,
                                    entry.getValue(),
                                    path + "/" + entry.getKey());
                        }
                    });
                } else if (currentShape.isStructureShape() || currentShape.isUnionShape()) {
                    currentValue.asObjectNode().ifPresent(v -> {
                        extract(result,
                                nextShape,
                                segmentPosition + 1,
                                v.getMember(segment).orElse(Node.nullNode()),
                                path + "/" + segment);
                    });
                }
            });
        }
Finds breaking changes related to when a trait is added, removed, or
updated based on the breakingChanges property of traits.
smithy-diff/src/main/java/software/amazon/smithy/diff/evaluators/TraitBreakingChange.java