static <T extends CompoundPredicate> T flattenCompound(Predicate predicateLeft, Predicate predicateRight, Class<T> klass) {
        // The following could have been achieved with {@link com.hazelcast.query.impl.predicates.FlatteningVisitor},
        // however since we only care for 2-argument flattening, we can avoid constructing a visitor and its internals
        // for each token pass at the cost of the following explicit code.
        Predicate[] predicates;
        if (klass.isInstance(predicateLeft) || klass.isInstance(predicateRight)) {
            Predicate[] left = getSubPredicatesIfClass(predicateLeft, klass);
            Predicate[] right = getSubPredicatesIfClass(predicateRight, klass);

            predicates = new Predicate[left.length + right.length];
            ArrayUtils.concat(left, right, predicates);
        } else {
            predicates = new Predicate[]{predicateLeft, predicateRight};
        }
        try {
            T compoundPredicate = klass.getDeclaredConstructor().newInstance();
            compoundPredicate.setPredicates(predicates);
            return compoundPredicate;
        } catch (ReflectiveOperationException e) {
            throw new IllegalArgumentException(String.format("%s must have a public default constructor", klass.getName()));
        }
    }
@Test
    public void testOr_whenNoPredicateOr() {
        Predicate<Object, Object> predicate1 = Predicates.alwaysTrue();
        Predicate<Object, Object> predicate2 = Predicates.alwaysTrue();
        OrPredicate concatenatedOr = SqlPredicate.flattenCompound(predicate1, predicate2, OrPredicate.class);
        assertEquals(2, concatenatedOr.getPredicates().length);
        assertSame(predicate1, concatenatedOr.getPredicates()[0]);
        assertSame(predicate2, concatenatedOr.getPredicates()[1]);
    }