code: private static Type buildResultType(final Class<?> type,
                                          final Set<Class<?>> contracts,
                                          final Map<Class<?>, LinkedHashMap<String, Type>> firstContext,
                                          final Map<Class<?>, LinkedHashMap<String, Type>> secondContext,
                                          final boolean alwaysIncludeInterfaces,
                                          final PathsCache cache) {
  
          removeDuplicateContracts(type, contracts);
  
          final List<Type> res = new ArrayList<Type>();
          if (type != Object.class) {
              res.add(buildCommonType(type, firstContext, secondContext, alwaysIncludeInterfaces, cache));
          }
  
          // resolve interfaces only for root type resolution or if root class cant be found
          if (alwaysIncludeInterfaces || res.isEmpty()) {
              for (Class<?> iface : contracts) {
                  // simpler resolution for contracts (only class to prevent cycles)
                  res.add(buildCommonType(iface, firstContext, secondContext, false, cache));
              }
              // sort found types by specificity:
              // class -> interface from non java package -> interface with generic -> sort by name
              // in order to always get predictable order and so always the same resolution
              Collections.sort(res, TYPE_COMPARATOR);
          }
  
          return res.isEmpty() ? Object.class
                  : res.size() == 1 ? res.iterator().next()
                  : WildcardTypeImpl.upper(res.toArray(new Type[0]));
      }
docs: When first level commodity found, complete types must be build (including all generics) so the entire
  process is restarted for generic types and using all this final type is built.
  <p>
  This is the only place where {@code alwaysIncludeInterfaces} actually required! When full type is enabled,
  not only base class will be resolved, but also all common interfaces (to provide the most complete
  type without accuracy lost). If base class is not detected then all detected interfaces are simply returned
  as wildcard (of course if only 1 interface found, it's directly returned without wildcard wrapper).
  
  @param type                    common root class
  @param contracts               common interfaces
  @param firstContext            first type generics context
  @param secondContext           second type generics context
  @param alwaysIncludeInterfaces always search for common interfaces
  @param cache                   resolution types cache
  @return final median type for original types