@Test
public void testIterator() {

  for (int iter = 0; iter < 10; iter++) {
    FoldedTreeSet<Holder> set = new FoldedTreeSet<>();
    long[] longs = new long[64723];
    for (int i = 0; i < longs.length; i++) {
      Holder val = new Holder(srand.nextLong());
      while (set.contains(val)) {
        val = new Holder(srand.nextLong());
      }
      longs[i] = val.getId();
      set.add(val);
    }
    assertEquals(longs.length, set.size());
    Arrays.sort(longs);
    Iterator<Holder> it = set.iterator();
    for (int i = 0; i < longs.length; i++) {
      assertTrue(it.hasNext());
      Holder val = it.next();
      assertEquals(longs[i], val.getId());
      // remove randomly to force non linear removes
      if (srand.nextBoolean()) {
        it.remove();
      }
    }
  }
}