public static Predicate[] acceptVisitor(Predicate[] predicates, Visitor visitor, IndexRegistry indexes) {
        Predicate[] target = predicates;
        boolean copyCreated = false;
        for (int i = 0; i < predicates.length; i++) {
            Predicate predicate = predicates[i];
            if (predicate instanceof VisitablePredicate visitablePredicate) {
                Predicate transformed = visitablePredicate.accept(visitor, indexes);
                if (transformed != predicate) {
                    if (!copyCreated) {
                        copyCreated = true;
                        target = createCopy(target);
                    }
                    target[i] = transformed;
                }
            }
        }
        return target;
    }
@Test
    public void acceptVisitor_whenNoChange_thenReturnOriginalArray() {
        Visitor mockVisitor = mock(Visitor.class);

        Predicate[] predicates = new Predicate[1];
        Predicate predicate = createMockVisitablePredicate();
        predicates[0] = predicate;

        Predicate[] result = VisitorUtils.acceptVisitor(predicates, mockVisitor, mockIndexes);
        assertThat(result).isSameAs(predicates);
    }