@SuppressWarnings("unchecked")
	private static <T extends DataType> T findDataType(DataTypeManager dataTypeManager,
			String dtName, Class<T> classConstraint, NamespaceMatcher categoryMatcher) {

		ArrayList<DataType> list = new ArrayList<>();
		dataTypeManager.findDataTypes(dtName, list);
		Collections.sort(list, DATATYPE_CATEGORY_PATH_LENGTH_COMPARATOR);
		if (!list.isEmpty()) {
			T secondaryMatch = null;
			for (DataType existingDT : list) {
				if (classConstraint != null &&
					!classConstraint.isAssignableFrom(existingDT.getClass())) {
					continue;
				}
				CategoryMatchType matchType =
					categoryMatcher.getMatchType(existingDT.getCategoryPath());
				if (matchType == CategoryMatchType.PREFERRED) {
					return (T) existingDT; // preferred match
				}
				else if (secondaryMatch == null && matchType == CategoryMatchType.SECONDARY) {
					secondaryMatch = (T) existingDT;
				}
			}
			return secondaryMatch;
		}
		return null;
	}
Perform a namespace qualified datatype search.  
@param dataTypeManager datatype manager
@param dtName datatype name
@param classConstraint type of datatype by its interface class (e.g., {@link Structure}).
@param categoryMatcher responsible for evaluating the category path
for a possible match with a namespace constraint.  
@return The first {@link CategoryMatchType#PREFERRED} match will be 
returned if found.  If none are {@link CategoryMatchType#PREFERRED}, the first 
{@link CategoryMatchType#SECONDARY} match will be returned.  Otherwise null is returned.
Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/data/DataTypeUtilities.java