@Test
    public void testRecursiveAnnotationIterationForC() {
        List<Annotation> cAnnotationsList = new ArrayList<>();
        for (Iterator<Annotation> iteratorc = tree.iteratorRecursive(c); iteratorc.hasNext(); ) {
            cAnnotationsList.add(iteratorc.next());
        }
        Collections.sort(cAnnotationsList);

        Iterator<Annotation> cAnnotations = cAnnotationsList.iterator();

        assertTrue(cAnnotations.hasNext());
        assertTrue(cAnnotations.hasNext());
        assertTrue(cAnnotations.hasNext());
        assertTrue(cAnnotations.hasNext());

        assertSame(dummyD, cAnnotations.next());
        assertSame(d, dummyD.getSpanNode());

        assertTrue(cAnnotations.hasNext());
        assertTrue(cAnnotations.hasNext());
        assertTrue(cAnnotations.hasNext());
        assertTrue(cAnnotations.hasNext());

        assertSame(grapeC, cAnnotations.next());
        assertSame(c, grapeC.getSpanNode());

        assertTrue(cAnnotations.hasNext());
        assertTrue(cAnnotations.hasNext());
        assertTrue(cAnnotations.hasNext());
        assertTrue(cAnnotations.hasNext());

        assertSame(bananaC, cAnnotations.next());
        assertSame(c, bananaC.getSpanNode());

        assertTrue(cAnnotations.hasNext());
        assertTrue(cAnnotations.hasNext());
        assertTrue(cAnnotations.hasNext());
        assertTrue(cAnnotations.hasNext());

        assertSame(appleC, cAnnotations.next());
        assertSame(c, appleC.getSpanNode());

        assertTrue(cAnnotations.hasNext());
        assertTrue(cAnnotations.hasNext());
        assertTrue(cAnnotations.hasNext());
        assertTrue(cAnnotations.hasNext());

        assertSame(dummyE, cAnnotations.next());
        assertSame(e, dummyE.getSpanNode());

        assertFalse(cAnnotations.hasNext());
        assertFalse(cAnnotations.hasNext());
        assertFalse(cAnnotations.hasNext());
        assertFalse(cAnnotations.hasNext());
    }
Tests iterating through C's annotations in a tree.
document/src/test/java/com/yahoo/document/annotation/SpanTreeTestCase.java