static Range consolidateRanges(List<RangeNode> ranges) {
        boolean consistent = true;
        Range result = new RangeImpl();
        for (RangeNode r : ranges) {
            Comparable lowValue = null;
            if (r.getStart() instanceof NumberNode startNode) {
                lowValue = startNode.getValue();
            } else if (r.getStart() instanceof AtLiteralNode atLiteralNode) {
                Object evaluated = MapperHelper.evaluateAtLiteralNode(atLiteralNode);
                lowValue = evaluated instanceof Comparable<?> ? (Comparable) evaluated : null;
            }
            if (lowValue != null) {
                if (result.getLowEndPoint() == null) {
                    result = new RangeImpl(Range.RangeBoundary.valueOf(r.getLowerBound().name()),
                                           lowValue,
                                           result.getHighEndPoint(), result.getHighBoundary());
                } else {
                    consistent = false;
                }
            }
            Comparable highValue = null;
            if (r.getEnd() instanceof NumberNode endNode) {
                highValue = endNode.getValue();
            } else if (r.getEnd() instanceof AtLiteralNode atLiteralNode) {
                Object evaluated = MapperHelper.evaluateAtLiteralNode(atLiteralNode);
                highValue = evaluated instanceof Comparable<?> ? (Comparable) evaluated : null;
            }
            if (highValue != null) {
                if (result.getHighEndPoint() == null) {
                    result = new RangeImpl(result.getLowBoundary(), result.getLowEndPoint(), highValue,
                                           Range.RangeBoundary.valueOf(r.getUpperBound().name()));
                } else {
                    consistent = false;
                }
            }
        }
        return consistent ? result : null;
    }
@Test
    void consolidateRangesForDateRange() {
        List<LocalDate> expectedDates = Arrays.asList(LocalDate.of(2022, 1, 1), LocalDate.of(2024, 1, 1));
        Range lowRange = new RangeImpl(Range.RangeBoundary.OPEN, expectedDates.get(0), null, Range.RangeBoundary.OPEN);
        Range highRange = new RangeImpl(Range.RangeBoundary.OPEN, null, expectedDates.get(1),
                                        Range.RangeBoundary.CLOSED);
        List<String> formattedDates = expectedDates.stream()
                .map(toFormat -> String.format("@\"%s-0%s-0%s\"", toFormat.getYear(), toFormat.getMonthValue(),
                                               toFormat.getDayOfMonth()))
                .toList();
        List<String> toRange = Arrays.asList(String.format("(%s .. null)", formattedDates.get(0)), String.format(
                "(null .. %s]", formattedDates.get(1)));
        List<RangeNode> ranges = getBaseNodes(toRange, RangeNode.class);
        Range retrieved = RangeNodeSchemaMapper.consolidateRanges(ranges);
        assertThat(retrieved).isNotNull().isEqualTo(new RangeImpl(lowRange.getLowBoundary(), lowRange.getLowEndPoint(),
                                                                  highRange.getHighEndPoint(),
                                                                  highRange.getHighBoundary()));
    }