@Test
    public void assertTree() {
        final SpanList root = (SpanList) tree.getRoot();
        //Level 0:
        assertEquals(0, root.getFrom());
        assertEquals(35, root.getTo());
        assertEquals(6, root.numChildren());

        //Level 1:
        assertTrue(root.children().get(0) instanceof Span);
        assertEquals(15, root.children().get(0).getFrom());
        assertEquals(35, root.children().get(0).getTo());
        assertFalse(root.children().get(0).childIterator().hasNext());
        assertFalse(tree.iterator(root.children().get(0)).hasNext());

        assertTrue(root.children().get(1) instanceof Span);
        assertEquals(15, root.children().get(1).getFrom());
        assertEquals(25, root.children().get(1).getTo());
        assertFalse(root.children().get(1).childIterator().hasNext());
        assertFalse(tree.iterator(root.children().get(1)).hasNext());

        assertTrue(root.children().get(2) instanceof Span);
        assertEquals(5, root.children().get(2).getFrom());
        assertEquals(15, root.children().get(2).getTo());
        assertFalse(root.children().get(2).childIterator().hasNext());
        assertFalse(tree.iterator(root.children().get(2)).hasNext());

        assertTrue(root.children().get(3) instanceof Span);
        assertEquals(0, root.children().get(3).getFrom());
        assertEquals(5, root.children().get(3).getTo());
        assertFalse(root.children().get(3).childIterator().hasNext());
        assertFalse(tree.iterator(root.children().get(3)).hasNext());

        assertTrue(root.children().get(4) instanceof SpanList);
        assertFalse(root.children().get(4) instanceof AlternateSpanList);
        assertEquals(4, root.children().get(4).getFrom());
        assertEquals(9, root.children().get(4).getTo());
        assertTrue(root.children().get(4).childIterator().hasNext());
        assertFalse(tree.iterator(root.children().get(4)).hasNext());

        assertTrue(root.children().get(5) instanceof AlternateSpanList);
        assertEquals(-1, root.children().get(5).getFrom());
        assertEquals(-1, root.children().get(5).getTo());
        assertTrue(root.children().get(5).childIterator().hasNext());
        assertFalse(tree.iterator(root.children().get(5)).hasNext());


        //Level 2:
        final SpanList list1 = (SpanList) root.children().get(4);
        assertFalse(list1 instanceof AlternateSpanList);
        assertEquals(1, list1.numChildren());

        assertTrue(list1.children().get(0) instanceof Span);
        assertEquals(4, list1.children().get(0).getFrom());
        assertEquals(9, list1.children().get(0).getTo());
        assertFalse(list1.children().get(0).childIterator().hasNext());
        assertFalse(tree.iterator(list1.children().get(0)).hasNext());

        final AlternateSpanList altList1 = (AlternateSpanList) root.children().get(5);
        assertEquals(3, altList1.getNumSubTrees());

        List<SpanNode> subTree0 = altList1.children(0);
        assertEquals(1, subTree0.size());

        assertTrue(subTree0.get(0) instanceof AlternateSpanList); //TODO: Assert on this!!
        assertEquals(3, ((AlternateSpanList) subTree0.get(0)).getNumSubTrees());
        List<SpanNode> subTree0_0 = ((AlternateSpanList) subTree0.get(0)).children(0);
        assertEquals(0, subTree0_0.size());
        List<SpanNode> subTree0_1 = ((AlternateSpanList) subTree0.get(0)).children(1);
        assertEquals(1, subTree0_1.size());
        List<SpanNode> subTree0_2 = ((AlternateSpanList) subTree0.get(0)).children(2);
        assertEquals(1, subTree0_2.size());

        assertEquals(-1, subTree0.get(0).getFrom());
        assertEquals(-1, subTree0.get(0).getTo());
        assertTrue(subTree0.get(0).childIterator().hasNext());
        assertFalse(tree.iterator(subTree0.get(0)).hasNext());

        List<SpanNode> subTree1 = altList1.children(1);
        assertEquals(1, subTree1.size());

        assertTrue(subTree1.get(0) instanceof SpanList);
        assertFalse(subTree1.get(0) instanceof AlternateSpanList);
        assertEquals(0, subTree1.get(0).getFrom());
        assertEquals(22, subTree1.get(0).getTo());
        assertTrue(subTree1.get(0).childIterator().hasNext());
        assertFalse(tree.iterator(subTree1.get(0)).hasNext());

        List<SpanNode> subTree2 = altList1.children(2);
        assertEquals(1, subTree2.size());

        assertTrue(subTree2.get(0) instanceof SpanList);
        assertFalse(subTree2.get(0) instanceof AlternateSpanList);
        assertEquals(0, subTree2.get(0).getFrom());
        assertEquals(22, subTree2.get(0).getTo());
        assertTrue(subTree2.get(0).childIterator().hasNext());
        assertFalse(tree.iterator(subTree2.get(0)).hasNext());

        //NOTE subTree2 has children


        //Level 3
        assertTrue(subTree0_0.isEmpty());

        final Span subTree0_1_0 = (Span) subTree0_1.get(0);
        assertEquals(1, subTree0_1_0.getFrom());
        assertEquals(5, subTree0_1_0.getTo());
        assertFalse(subTree0_1_0.childIterator().hasNext());
        final Iterator<Annotation> subTree0_1_0AnnIterator = tree.iterator(subTree0_1_0);
        assertTrue(subTree0_1_0AnnIterator.hasNext());
        Annotation subTree0_1_0Annotation = subTree0_1_0AnnIterator.next();
        //TODO: Assert on annotation
        assertFalse(subTree0_1_0AnnIterator.hasNext());


        final Span subTree0_2_0 = (Span) subTree0_2.get(0);
        assertEquals(6, subTree0_2_0.getFrom());
        assertEquals(16, subTree0_2_0.getTo());
        assertFalse(subTree0_2_0.childIterator().hasNext());
        final Iterator<Annotation> subTree0_2_0AnnIterator = tree.iterator(subTree0_2_0);
        assertTrue(subTree0_2_0AnnIterator.hasNext());
        Annotation subTree0_2_0Annotation = subTree0_2_0AnnIterator.next();
        //TODO: Assert on annotation
        assertFalse(subTree0_2_0AnnIterator.hasNext());


        final SpanList sl = (SpanList) subTree1.get(0);
        assertFalse(sl instanceof AlternateSpanList);
        assertEquals(3, sl.children().size());

        assertTrue(sl.children().get(0) instanceof Span);
        assertEquals(0, sl.children().get(0).getFrom());
        assertEquals(3, sl.children().get(0).getTo());
        assertFalse(sl.children().get(0).childIterator().hasNext());
        final Iterator<Annotation> iterator0 = tree.iterator(sl.children().get(0));
        assertTrue(iterator0.hasNext());
        Annotation iterator0Annotation = iterator0.next();
        //TODO: Assert on annotation
        assertFalse(iterator0.hasNext());

        assertTrue(sl.children().get(1) instanceof Span);
        assertEquals(1, sl.children().get(1).getFrom());
        assertEquals(10, sl.children().get(1).getTo());
        assertFalse(sl.children().get(1).childIterator().hasNext());
        final Iterator<Annotation> iterator1 = tree.iterator(sl.children().get(1));
        assertTrue(iterator1.hasNext());
        Annotation iterator1Annotation = iterator1.next();
        //TODO: Assert on annotation
        assertFalse(iterator1.hasNext());

        assertTrue(sl.children().get(2) instanceof Span);
        assertEquals(12, sl.children().get(2).getFrom());
        assertEquals(22, sl.children().get(2).getTo());
        assertFalse(sl.children().get(2).childIterator().hasNext());
        final Iterator<Annotation> iterator2 = tree.iterator(sl.children().get(2));
        assertTrue(iterator2.hasNext());
        Annotation iterator2Annotation = iterator2.next();
        //TODO: Assert on annotation
        assertFalse(iterator2.hasNext());

        final SpanList sl2 = (SpanList) subTree2.get(0);
        assertFalse (sl2 instanceof AlternateSpanList);
        assertEquals(3, sl2.children().size());

        assertTrue(sl2.children().get(0) instanceof Span);
        assertEquals(12, sl2.children().get(0).getFrom());
        assertEquals(22, sl2.children().get(0).getTo());
        assertFalse(sl2.children().get(0).childIterator().hasNext());
        final Iterator<Annotation> iterator3 = tree.iterator(sl2.children().get(0));
        assertTrue(iterator3.hasNext());
        Annotation iterator3Annotation = iterator3.next();
        //TODO: Assert on annotation
        assertFalse(iterator3.hasNext());

        assertTrue(sl2.children().get(1) instanceof Span);
        assertEquals(1, sl2.children().get(1).getFrom());
        assertEquals(10, sl2.children().get(1).getTo());
        assertFalse(sl2.children().get(1).childIterator().hasNext());
        final Iterator<Annotation> iterator4 = tree.iterator(sl2.children().get(1));
        assertTrue(iterator4.hasNext());
        Annotation iterator4Annotation = iterator4.next();
        //TODO: Assert on annotation
        assertFalse(iterator4.hasNext());

        assertTrue(sl2.children().get(2) instanceof Span);
        assertEquals(0, sl2.children().get(2).getFrom());
        assertEquals(3, sl2.children().get(2).getTo());
        assertFalse(sl2.children().get(2).childIterator().hasNext());
        final Iterator<Annotation> iterator5 = tree.iterator(sl2.children().get(2));
        assertTrue(iterator5.hasNext());
        Annotation iterator5Annotation = iterator5.next();
        //TODO: Assert on annotation
        assertFalse(iterator5.hasNext());

    }
@author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a>
document/src/test/java/com/yahoo/document/annotation/Bug4155865TestCase.java