@Test
    public void assertTree_NodeSet1() {
        if (debug) consumeAnnotations(tree, root);
        assertEquals(-1, root.getFrom());
        assertEquals(-1, root.getTo());
        assertEquals(-1, branch.getFrom());
        assertEquals(-1, branch.getTo());
        assertEquals(0, branch.getFrom(1));
        assertEquals(22, branch.getTo(1));
        assertEquals(0, branch.getFrom(2));
        assertEquals(22, branch.getTo(2));
        assertEquals(3, branch.getNumSubTrees());
        int no = branch.getNumSubTrees();

        TreeSet<Double> set = new TreeSet<Double>();
        for (int i = 0; i < no; i ++) {
            double prob = branch.getProbability(i);
            set.add(prob);
        }

        branch.sortSubTreesByProbability();

        Iterator<Double> iter = set.descendingIterator();
        for (int i = 0; i < no; i ++) {
            double prob = branch.getProbability(i);
            double prob1 = iter.next();
            assertTrue(prob == prob1);
        }
        branch.normalizeProbabilities();
        double highest = 0;
        for (int i = 0; i < no; i ++) {
            double prob = branch.getProbability(i);
            if (i == 0) {
                highest = prob;
                continue;
            }
            assertFalse(prob >= highest || prob > 1.0);
            highest = prob;
        }

        ListIterator<SpanNode> it = branch.childIterator();
        assertSame(alternate2, it.next());
        assertSame(alternate1, it.next());
        assertFalse(it.hasNext());

        SpanNode sn;

        it = branch.childIteratorRecursive();
        assertSame(span11, it.next());
        assertSame(span22, it.next());
        assertSame(span33, it.next());
        assertSame(alternate2, it.next());
        assertSame(span3, it.next());
        assertSame(span2, it.next());
        assertSame(span1, it.next());
        assertSame(alternate1, it.next());
        assertFalse(it.hasNext());


        it = branch.childIterator(1);
        assertSame(alternate1, it.next());
        assertFalse(it.hasNext());


        SpanNode snNew = new Span(15, 20);
        List<SpanNode> alternate3 = new ArrayList<SpanNode>();
        alternate3.add(snNew);
        List<SpanNode> l = branch.setChildren(0, alternate3, 200.0d);
        assertFalse (l.get(0) != alternate2);
        assertFalse (branch.getProbability(0) != 200.0);

        String s = branch.toString();
        tree.cleanup();
        boolean dMode = debug;
        debug = false;
        consumeAnnotations(tree, root);
        debug = dMode;

        branch.setProbability(0, 125.0d);
        branch.setProbability(1, 75.0d);
        branch.setProbability(2, 25.0d);
        branch.sortSubTreesByProbability();
        double initial = 125.0;
        for (int j = 0; j < no; j++) {
            double prob = branch.getProbability(j);
            assertFalse (prob != initial);
            initial = initial - 50.0d;
        }
        no = branch.getNumSubTrees();

        for (int j = 0; j < no; no --) {
            branch.removeChildren(j);
        }

        assertFalse (branch.getNumSubTrees() != 1);
        assertFalse(branch.getProbability(0) != 1.0);
        branch.addChildren(1, subtreeList1, 20.0d);
        branch.addChildren(2, subtreeList2, 50.0d);

        no = branch.getNumSubTrees();
        assertFalse (no != 3);
        branch.clearChildren();
        assertFalse (branch.getNumSubTrees() != 3);
        assertFalse(branch.getProbability(0) != 1.0);

        branch.addChildren(1, subtreeList1, 20.0d);
        branch.addChildren(2, subtreeList2, 50.0d);
        no = branch.getNumSubTrees();
        assertFalse (no != 5);
        branch.clearChildren(1);
        assertTrue (branch.getNumSubTrees() == no);
        assertEquals(branch.getFrom(1), -1);
        assertEquals(branch.getTo(1), -1);
        assertTrue(branch.getProbability(1) == 20.0);

        ListIterator<SpanNode> lit = branch.childIteratorRecursive(1);
        assertFalse(lit.hasNext());
        SpanNode newNode = new Span(10, 10);
        branch.add(0, newNode);
        lit = branch.childIteratorRecursive();
        assertTrue(lit.hasNext());
        assertFalse(lit.next() != newNode);

        branch.removeChildren(1);
        assertTrue (branch.getNumSubTrees() == (no-1));

        branch.removeChildren();
        no = branch.getNumSubTrees();
        assertTrue (no == 1);
        assertTrue (branch.getProbability(0) == 1.0);
        assertEquals(branch.getFrom(), -1);
        assertEquals(branch.getTo(), -1);

        buildTree_List();

        CharSequence fieldValue = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
        String actual = branch.getText(1, fieldValue).toString();
        String expected = "MNOPQRSTUVBCDEFGHIJABC";
        assertEquals(actual, expected);
    }
@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