code: private static Type resolveCommonType(final Type first,
                                            final Type second,
                                            final boolean alwaysIncludeInterfaces,
                                            final PathsCache cache) {
          // resolve complete hierarchies, preserving all generics
          // (even if types are ParameterizedType it will be counted)
          final Map<Class<?>, LinkedHashMap<String, Type>> firstContext = resolveHierarchy(first);
          final Map<Class<?>, LinkedHashMap<String, Type>> secondContext = resolveHierarchy(second);
  
          // all types in hierarchies
          final Set<Class<?>> firstComposingTypes = new HashSet<Class<?>>(firstContext.keySet());
          final Set<Class<?>> secondComposingTypes = new HashSet<Class<?>>(secondContext.keySet());
  
          Class<?> commonRoot = Object.class;
          final Set<Class<?>> commonContracts = new HashSet<Class<?>>();
  
          for (Class<?> type : firstComposingTypes) {
              if (secondComposingTypes.contains(type)) {
                  if (type.isInterface()) {
                      commonContracts.add(type);
                  } else {
                      // but it might be less specific as hierarchies contain all classes till Object
                      if (commonRoot.isAssignableFrom(type)) {
                          commonRoot = type;
                      }
                  }
              }
          }
  
          return buildResultType(
                  commonRoot, commonContracts, firstContext, secondContext, alwaysIncludeInterfaces, cache);
      }
docs: Pure search for median type without edge cases checks (no arrays or wildcards and not equal types).
  Complete hierarchies are resolved for both types in order to find minimal base class and all
  common interfaces.
  
  @param first                   first type
  @param second                  second type
  @param alwaysIncludeInterfaces always search for common interfaces
  @param cache                   resolution types cache
  @return resolved common type or Object if no commodity found