FieldExpression sub = (FieldExpression) nestedExpression.getExpression(i);
    private Class getQueryClass(com.opensymphony.workflow.query.Expression expr, Collection classesCache) throws StoreException {        if (classesCache == null) {            classesCache = new HashSet();        }        if (expr instanceof FieldExpression) {            FieldExpression fieldExpression = (FieldExpression) expr;            switch (fieldExpression.getContext()) {            case FieldExpression.CURRENT_STEPS:                classesCache.add(HibernateCurrentStep.class);                break;            case FieldExpression.HISTORY_STEPS:                classesCache.add(HibernateHistoryStep.class);                break;            case FieldExpression.ENTRY:                classesCache.add(HibernateWorkflowEntry.class);                break;            default:                throw new StoreException("Query for unsupported context " + fieldExpression.getContext());            }        } else {            NestedExpression nestedExpression = (NestedExpression) expr;            for (int i = 0; i < nestedExpression.getExpressionCount(); i++) {                com.opensymphony.workflow.query.Expression expression = nestedExpression.getExpression(i);                if (expression.isNested()) {                    classesCache.add(getQueryClass(nestedExpression.getExpression(i), classesCache));                } else {                    FieldExpression sub = (FieldExpression) nestedExpression.getExpression(i);                    classesCache.add(getQueryClass(expression, classesCache));                }            }        }        if (classesCache.size() > 1) {            throw new StoreException("Store does not support nested queries of different types (types found:" + classesCache + ")");        }        return (Class) classesCache.iterator().next();    }