@Test
public void testHeadSum() {

    AVLGroupTree x = new AVLGroupTree(false);
    for (int i = 0; i < 1000; ++i) {
        x.add(randomDouble(), randomIntBetween(1, 10), null);
    }
    long sum = 0;
    long last = -1;
    for (int node = x.first(); node != IntAVLTree.NIL; node = x.next(node)) {
        assertEquals(sum, x.headSum(node));
        sum += x.count(node);
        last = x.count(node);
    }
    assertEquals(last, x.count(x.last()));
}