private QueryCriteria queryCriteriaCase(
        AttributeQueryCriteria criteria, List<AttributeReference.Key> arg) {
      final AttributeReference basicAttRef;
      if (arg.isEmpty()) {
        basicAttRef = criteria.getAttributeReference();
      } else {
        basicAttRef = criteria.getAttributeReference().prepend(arg);
      }

      DisjunctionBuilder disjunctionBuilder = new DisjunctionBuilder();

      disjunctionBuilder.add(criteria);

      for (int i = 0; i < basicAttRef.getKeys().size(); i++) {
        AttributeReference existsAttRef = basicAttRef.subReference(0, i + 1);

        List<AttributeReference.Key> newArg =
            basicAttRef.getKeys().subList(i + 1, basicAttRef.getKeys().size());

        QueryCriteria plainNewBody = criteria.accept(QUERY_CRITERIA_FACTORY, newArg);

        QueryCriteria newBody =
            plainNewBody.accept(this, Collections.<AttributeReference.Key>emptyList());

        disjunctionBuilder.add(new ExistsQueryCriteria(existsAttRef, newBody));
      }

      return disjunctionBuilder.build();
    }
    private Set<AttributeReference> combineAttributeReferences(AttributeReference attRef) {
      Set<AttributeReference> result = Sets.newHashSetWithExpectedSize(attRef.getKeys().size());

      combineAttributeReferencesRec(
          attRef.getKeys(), Lists.<AttributeReference.Key>newArrayList(), result);

      return result;
    }