@Test
    public void testSimpleCopy2() {
        StringFieldValue string = new StringFieldValue("yahoooo");

        SpanList list = new SpanList();
        Span span1 = new Span(0,1);
        Span span2 = new Span(1,1);
        list.add(span1).add(span2);
        SpanTree tree = new SpanTree("foo", list);
        string.setSpanTree(tree);

        Annotation a1 = new Annotation(grape);
        tree.annotate(span1, a1);
        Annotation a2 = new Annotation(apple);
        tree.annotate(span2, a2);

        Struct donald = new Struct(person);
        donald.setFieldValue("firstname", "donald");
        donald.setFieldValue("lastname", "duck");
        donald.setFieldValue("birthyear", 1929);
        Annotation donaldAnn = new Annotation(personA, donald);
        tree.annotate(list, donaldAnn);


        StringFieldValue stringCopy = string.clone();



        assertEquals(string, stringCopy);
        assertNotSame(string, stringCopy);

        SpanTree treeCopy = stringCopy.getSpanTree("foo");
        assertEquals(tree, treeCopy);
        assertNotSame(tree, treeCopy);

        SpanList listCopy = (SpanList) treeCopy.getRoot();
        assertEquals(list, listCopy);
        assertNotSame(list, listCopy);

        Span span1Copy = (Span) listCopy.children().get(0);
        assertEquals(span1, span1Copy);
        assertNotSame(span1, span1Copy);

        Span span2Copy = (Span) listCopy.children().get(1);
        assertEquals(span2, span2Copy);
        assertNotSame(span2, span2Copy);

        Iterator<Annotation> annotationIt;
        {
            List<Annotation> allAnnotationsList = new ArrayList<>();
            for (Annotation an : treeCopy) {
                allAnnotationsList.add(an);
            }
            Collections.sort(allAnnotationsList);

            annotationIt = allAnnotationsList.iterator();
        }

        Annotation a1Copy = annotationIt.next();
        assertEquals(a1, a1Copy);
        assertNotSame(a1, a1Copy);
        assertSame(span1Copy, a1Copy.getSpanNode());
        assertNotSame(span1, a1Copy.getSpanNode());

        Annotation donaldAnnCopy = annotationIt.next();
        assertEquals(donaldAnn, donaldAnnCopy);
        assertNotSame(donaldAnn, donaldAnnCopy);
        assertSame(listCopy, donaldAnnCopy.getSpanNode());
        assertNotSame(list, donaldAnnCopy.getSpanNode());

        Struct donaldCopy = (Struct) donaldAnnCopy.getFieldValue();
        assertEquals(donald, donaldCopy);
        assertNotSame(donald, donaldCopy);

        Annotation a2Copy = annotationIt.next();
        assertEquals(a2, a2Copy);
        assertNotSame(a2, a2Copy);
        assertSame(span2Copy, a2Copy.getSpanNode());
        assertNotSame(span2, a2Copy.getSpanNode());
    }
Tests iterating through E's annotations in a tree.
document/src/test/java/com/yahoo/document/annotation/SpanTreeTestCase.java