private void setCorrectAnnotationReference(FieldValue value, IdentityHashMap<Annotation, Integer> originalAnnotations, List<Annotation> newAnnotations) {
        if (value == null) {
            return;
        }

        if (value.getDataType() instanceof AnnotationReferenceDataType) {
            AnnotationReference ref = (AnnotationReference) value;
            if (ref.getReference() == null) {
                return;
            }
            Integer referenceIndex = originalAnnotations.get(ref.getReference());
            if (referenceIndex == null) {
                throw new IllegalStateException("Cannot find Annotation pointed to by " + ref);
            }
            try {
                Annotation newReference = newAnnotations.get(referenceIndex);
                ref.setReference(newReference);
            } catch (IndexOutOfBoundsException ioobe) {
                throw new IllegalStateException("Cannot find Annotation pointed to by " + ref, ioobe);
            }
        } else if (value.getDataType() instanceof StructuredDataType) {
            setCorrectAnnotationReference((StructuredFieldValue) value, originalAnnotations, newAnnotations);
        } else if (value.getDataType() instanceof CollectionDataType) {
            setCorrectAnnotationReference((CollectionFieldValue) value, originalAnnotations, newAnnotations);
        } else if (value.getDataType() instanceof MapDataType) {
            setCorrectAnnotationReference((MapFieldValue) value, originalAnnotations, newAnnotations);
        }
    }
Creates a new SpanTree with the given name and an empty SpanList as its root node.

@param name the name of the span tree
document/src/main/java/com/yahoo/document/annotation/SpanTree.java