public static boolean overlapsOrdered(IndexIterationPointer left, IndexIterationPointer right, Comparator comparator) {
        assert left.isDescending() == right.isDescending() : "Cannot compare pointer with different directions";
        assert left.lastEntryKeyData == null && right.lastEntryKeyData == null : "Can merge only initial pointers";

        // fast path for the same instance
        if (left == right) {
            return true;
        }

        assert comparator.compare(left.from, right.from) <= 0 : "Pointers must be ordered";

        // if one of the ends is +/-inf respectively -> overlap
        if (left.to == null || right.from == null) {
            return true;
        }

        // if given end is equal the ranges overlap (or at least are adjacent)
        // if at least one of the ranges is inclusive
        boolean eqOverlaps = left.isToInclusive() || right.isFromInclusive();

        // Check non-inf values, do not need to check the other way around because pointers are ordered
        // Thanks to order we do not have to check `right.to`, we only need to check
        // if `right.from` belongs to `left` pointer range.
        // we must take into account inclusiveness, so we do not merge < X and > X ranges
        int rfCmpLt = comparator.compare(right.from, left.to);
        return eqOverlaps ? rfCmpLt <= 0 : rfCmpLt < 0;
    }
@Test
    void overlapsOrderedSingleton() {
        assertTrue(overlapsOrdered(pointer(singleton(5)), pointer(singleton(5)),
                OrderedIndexStore.SPECIAL_AWARE_COMPARATOR), "singleton value should overlap with itself");
        assertFalse(overlapsOrdered(pointer(singleton(5)), pointer(singleton(6)),
                OrderedIndexStore.SPECIAL_AWARE_COMPARATOR), "singleton value should not overlap with different singleton");
        assertFalse(overlapsOrdered(pointer(singleton(5), true), pointer(singleton(6), true),
                OrderedIndexStore.SPECIAL_AWARE_COMPARATOR), "singleton value should not overlap with different singleton");
    }