public MutableTree<K> beginWrite() {
        return new MutableTree<>(this);
    }
@Test
    public void tailReverseIterationTest() {
        Random random = new Random(239786);
        Persistent23Tree.MutableTree<Integer> tree = new Persistent23Tree<Integer>().beginWrite();
        int[] p = genPermutation(random);
        TreeSet<Integer> added = new TreeSet<>();
        for (int i = 0; i < ENTRIES_TO_ADD; i++) {
            int size = tree.size();
            Assert.assertEquals(i, size);
            if ((size & 1023) == 0 || size < 100) {
                if (i > 0) {
                    checkTailReverseIteration(tree, added, added.first());
                    checkTailReverseIteration(tree, added, added.first() - 1);
                    checkTailReverseIteration(tree, added, added.last());
                    checkTailReverseIteration(tree, added, added.last() + 1);
                }
                checkTailReverseIteration(tree, added, Integer.MAX_VALUE);
                checkTailReverseIteration(tree, added, Integer.MIN_VALUE);
                for (int j = 0; j < 10; j++) {
                    checkTailReverseIteration(tree, added, p[i * j / 10]);
                }
            }
            tree.add(p[i]);
            added.add(p[i]);
        }
    }