@SuppressWarnings("rawtypes")
    private static <T> Path<T> replaceParent(Path<T> path, Path<?> parent) {
        PathMetadata metadata = new PathMetadata(parent, path.getMetadata().getElement(),
                path.getMetadata().getPathType());
        if (path instanceof CollectionExpression) {
            CollectionExpression<?,?> col = (CollectionExpression<?,?>) path;
            return (Path<T>) Expressions.listPath(col.getParameter(0), SimplePath.class, metadata);
        } else {
            return ExpressionUtils.path(path.getType(), metadata);
        }
    }
{@code CollectionAnyVisitor} is an expression visitor which transforms any() path expressions which are
often transformed into subqueries

@author tiwe
querydsl-core/src/main/java/com/querydsl/core/support/CollectionAnyVisitor.java