code: private Type resolveTypeVariable(TypeVariable<?> typeVariable, GenericType<?> declaringType, Class<?> declaringClass) {
  
      List<Type> hierarchy = getGenericDeclarations(declaringClass, declaringType.getRetrievalClass());
      if (hierarchy != null) {
        TypeVariable<?> currentVariable = typeVariable;
        for (int i = hierarchy.size() - 1; i >= -1; i--) {
          Type hierarchyType;
          if (i >= 0) {
            hierarchyType = hierarchy.get(i);
          } else {
            hierarchyType = declaringType.getType();
          }
          if (hierarchyType instanceof ParameterizedType) {
            ParameterizedType pt = (ParameterizedType) hierarchyType;
            Type[] typeArguments = pt.getActualTypeArguments();
            int variableIndex = getDeclarationIndex(currentVariable);
            if (variableIndex >= 0) {
              Type typeArgument = typeArguments[variableIndex];
              if (typeArgument instanceof TypeVariable<?>) {
                currentVariable = (TypeVariable<?>) typeArgument;
              } else {
                return typeArgument;
              }
            }
          }
        }
        if (currentVariable != typeVariable) {
          // NOT really resolved, but maybe bounds are more specific...
          return currentVariable;
        }
      }
      GenericType<?> definingType = ((AbstractGenericType<?>) declaringType).getDefiningType();
      if (definingType != null) {
        return resolveTypeVariable(typeVariable, definingType, declaringClass);
      }
      return null;
    }
docs: This method recursively resolves the given {@code typeVariable} in the context of the given
  {@code declaringType}.
  
  @param typeVariable the {@link TypeVariable} to resolve.
  @param declaringType the {@link GenericType} where the given {@code typeVariable} occurs or is replaced.
  @param declaringClass the {@link TypeVariable#getGenericDeclaration() declaring class}.
  @return the resolved {@link Type} or {@code null} if the given {@code typeVariable} could NOT be resolved
  (e.g. it was {@link TypeVariable#getGenericDeclaration() declared} in a {@link Class} that is NOT
  {@link Class#isAssignableFrom(Class) assignable from} the given {@code declaringType}) .