private static void computeTextInstancesForAppliedTrait(
            Node node,
            Trait trait,
            Shape parentShape,
            Collection<TextInstance> textInstances,
            Deque<String> propertyPath,
            Model model,
            Shape currentTraitPropertyShape
    ) {
        if (trait.toShapeId().equals(ReferencesTrait.ID)) {
            //Skip ReferenceTrait because it is referring to other shape names already being checked
        } else if (node.isStringNode()) {
            textInstances.add(TextInstance.createTraitInstance(
                    node.expectStringNode().getValue(),
                    parentShape,
                    trait,
                    propertyPath));
        } else if (node.isObjectNode()) {
            ObjectNode objectNode = node.expectObjectNode();
            objectNode.getStringMap().entrySet().forEach(memberEntry -> {
                propertyPath.offerLast(memberEntry.getKey());
                Shape memberTypeShape = getChildMemberShapeType(memberEntry.getKey(),
                        model,
                        currentTraitPropertyShape);
                if (memberTypeShape == null) {
                    //This means the "property" key value isn't modeled in the trait's structure/shape definition
                    //and this text instance is unique
                    propertyPath.offerLast("key");
                    textInstances.add(TextInstance.createTraitInstance(
                            memberEntry.getKey(),
                            parentShape,
                            trait,
                            propertyPath));
                    propertyPath.removeLast();
                }
                computeTextInstancesForAppliedTrait(memberEntry.getValue(),
                        trait,
                        parentShape,
                        textInstances,
                        propertyPath,
                        model,
                        memberTypeShape);
                propertyPath.removeLast();
            });
        } else if (node.isArrayNode()) {
            int index = 0;
            for (Node nodeElement : node.expectArrayNode().getElements()) {
                propertyPath.offerLast(Integer.toString(index));
                Shape memberTypeShape = getChildMemberShapeType(null,
                        model,
                        currentTraitPropertyShape);
                computeTextInstancesForAppliedTrait(nodeElement,
                        trait,
                        parentShape,
                        textInstances,
                        propertyPath,
                        model,
                        memberTypeShape);
                propertyPath.removeLast();
                ++index;
            }
        }
    }
Index containing the full set of {@link TextInstance}s associated with a model.
smithy-model/src/main/java/software/amazon/smithy/model/knowledge/TextIndex.java