code: @SuppressWarnings("unchecked")
      public static Object convertToCollection(final Object result, final Class collectionType,
                                               final Class targetEntity, final boolean projection) {
          final Object converted;
          if (collectionType.equals(Iterator.class)) {
              converted = toIterator(result, targetEntity, projection);
          } else if (collectionType.isAssignableFrom(List.class)) {
              converted = Lists.newArrayList(toIterator(result, targetEntity, projection));
          } else if (collectionType.isAssignableFrom(Set.class)) {
              converted = Sets.newHashSet(toIterator(result, targetEntity, projection));
          } else if (!collectionType.isInterface()) {
              converted = convertToCollectionImpl(result, collectionType, targetEntity, projection);
          } else {
              throw new ResultConversionException(String.format(
                      "Incompatible result type requested %s for conversion from actual result %s",
                      collectionType, result.getClass()));
          }
          return converted;
      }
docs: Convert result object to collection. In some cases, this could be do nothing case, because orient already
  returns collection. If projection is required or when collection type is different from requested type,
  result will be re-packaged into the new collection.
  
  @param result         result instance
  @param collectionType target collection type
  @param targetEntity   target entity type
  @param projection     true to apply projection, false otherwise
  @return converted result