@Test
    public void assertTree_NodeSet2() {
        root = new SpanList();
        tree = new SpanTree("test", root);
        branch = new AlternateSpanList();

        Annotation an111 = new Annotation(at1, fv111);
        Annotation an222 = new Annotation(at2, fv222);

        branch0 = new SpanList();
        SpanNode span1 = new Span(0, 3);
        SpanNode span2 = new Span(3, 3);
        branch0.add(span1);
        branch0.add(span2);
        branch.add(branch0);

        ArrayList<SpanNode> list1 = new ArrayList<SpanNode>();
        branch2 = new AlternateSpanList();
        SpanNode sn1 = new Span(6, 4);
        SpanNode sn2 = new Span(10, 4);
        branch2.add(sn1);
        branch2.add(sn2);
        list1.add(branch2);
        branch.setProbability(0, 20.0d);
        branch.addChildren(1, list1, 30.0d);

        branch3 = new AlternateSpanList();
        SpanNode sn3 = new Span(15, 5);
        SpanNode sn4 = new Span(20, 5);
        ArrayList<SpanNode> list2 = new ArrayList<SpanNode>();
        list2.add(sn3);
        list2.add(sn4);
        branch3.addChildren(1, list2, 20.0d);
        branch3.setProbability(0, 10.0d);

        List<SpanNode> list3 = new ArrayList<SpanNode>();
        list3.add(branch3);
        branch2.addChildren(1, list3, 50.0d);
        branch2.setProbability(0, 25.0d);

        SpanNode sn5 = new Span(25, 3);
        branch3.add(sn5);

        root.add(branch);

        // Never bother. Just for debugging.
        if (debug) {
            System.out.println("===========NodeSet2 ================");
            consumeAnnotations(tree, root);
        }

        assertEquals(0, root.getFrom());
        assertEquals(6, root.getTo());
        assertEquals(0, branch.getFrom());
        assertEquals(6, branch.getTo());
        assertEquals(6, branch2.getFrom());
        assertEquals(14, branch2.getTo());
        assertEquals(25, branch2.getFrom(1));
        assertEquals(28, branch2.getTo(1));
        assertEquals(25, branch3.getFrom());
        assertEquals(28, branch3.getTo());
        assertEquals(15, branch3.getFrom(1));
        assertEquals(25, branch3.getTo(1));
        assertFalse ((branch.getNumSubTrees() != branch2.getNumSubTrees()) ||
            (branch.getNumSubTrees() != branch3.getNumSubTrees()));

        branch3.sortSubTreesByProbability();
        assertEquals(15, branch3.getFrom());
        assertEquals(25, branch3.getTo());
        assertEquals(25, branch3.getFrom(1));
        assertEquals(28, branch3.getTo(1));
    }
@author <a href="mailto:mpraveen@yahoo-inc.com">Praveen Mohan</a>

This test covers all possible scenarios in AlternateSpanList.
If you really want to debug, just turn on the debug flag to true.
document/src/test/java/com/yahoo/document/annotation/AlternateSpanListAdvTestCase.java