private static <T> Type walkClassHierarchyAndResolveTypes(Class<T> baseClass,
			Map<Type, Type> resolvedTypes, Type type) {

		if (type == null) {
			return null;
		}

		if (equals(type, baseClass)) {
			return type;
		}

		if (type instanceof Class) {

			Class<?> clazz = (Class<?>) type;
			Type[] interfaceTypes = clazz.getGenericInterfaces();
			Set<Type> toCheck = new HashSet<>();
			toCheck.addAll(Arrays.asList(interfaceTypes));

			Type parentType = clazz.getGenericSuperclass();
			toCheck.add(parentType);

			for (Type t : toCheck) {
				Type result = walkClassHierarchyAndResolveTypes(baseClass, resolvedTypes, t);
				if (equals(result, baseClass)) {
					return result;
				}
			}

			return parentType;
		}

		ParameterizedType parameterizedType = (ParameterizedType) type;
		Class<?> rawType = (Class<?>) parameterizedType.getRawType();
		Type[] actualTypeArguments = parameterizedType.getActualTypeArguments();
		TypeVariable<?>[] typeParameters = rawType.getTypeParameters();
		for (int i = 0; i < actualTypeArguments.length; i++) {
			resolvedTypes.put(typeParameters[i], actualTypeArguments[i]);
		}

		if (rawType.equals(baseClass)) {
			return rawType;
		}

		Type[] interfaceTypes = rawType.getGenericInterfaces();
		Set<Type> toCheck = new HashSet<>();
		toCheck.addAll(Arrays.asList(interfaceTypes));

		Type parentType = rawType.getGenericSuperclass();
		toCheck.add(parentType);

		for (Type t : toCheck) {
			Type result = walkClassHierarchyAndResolveTypes(baseClass, resolvedTypes, t);
			if (equals(result, baseClass)) {
				return result;
			}
		}

		return parentType;
	}
Returns the type arguments for the given base class and extension.

<p>Caveat: this lookup will only work if the given child class is a concrete class that
has its type arguments specified.  For example, these cases will work:
<pre>
		// anonymous class definition
		List&lt;String&gt; myList = new ArrayList&lt;String&gt;() {
			...
		};

		// class definition
		public class MyList implements List&lt;String&gt; {
</pre>

Whereas this case will not work:
<pre>
		// local variable with the type specified
		List&lt;String&gt; myList = new ArrayList&lt;String&gt;();
</pre>

<p>Note: a null entry in the result list will exist for any type that was unrecoverable


@param <T> the type of the base and child class
@param baseClass the base class
@param childClass the child class
@return the type arguments
Ghidra/Framework/Utility/src/main/java/utilities/util/reflection/ReflectionUtilities.java