private DecompilerVariable getMatch(DataType dt, FieldMatcher fieldMatcher,
			DecompilerVariable var, DecompilerVariable potentialField) {

		String indent = "\t\t";

		// Note: for now, I ignore the precedence of casting; if any cast type is a match, then
		//       signal hooray
		boolean searchForField = !fieldMatcher.isIgnored();
		DecompilerVariable fieldVar = searchForField ? potentialField : null;
		DecompilerVariable match = getMatchingVarialbe(dt, var, fieldVar);
		if (match == null) {
			DtrfDbg.println(this, indent + "NO MATCHING VARIABLE");
			return null; // wrong type, nothing to do
		}

		// Matches on the type, does the field match?
		if (fieldMatcher.isIgnored()) {
			DtrfDbg.println(this, indent + "field macher is ignored; returning match");
			return match; // no field to match
		}

		if (potentialField == null) {

			DtrfDbg.println(this, indent + "No potential field to match; name / offset match?");

			// check for the case where we have not been passed a 'potential field', but the given
			// 'var' is itself may be the field we seek, such as in an if statement like this:
			// 		if (color == RED)
			// where 'RED' is the variable we are checking
			String name = var.getName();
			int offset = var.getOffset();
			if (fieldMatcher.matches(name, offset)) {
				DtrfDbg.println(this, indent + "\tfield matcher matched on variable: " + var);
				return var;
			}

			DtrfDbg.println(this, indent + "\tNO FIELD MATCHER MATCH");
			return null; // we seek a field, but there is none
		}

		DtrfDbg.println(this, indent + "Checking 'potential field' match...");

		String name = potentialField.getName();
		int offset = potentialField.getOffset();
		if (fieldMatcher.matches(name, offset)) {
			DtrfDbg.println(this, indent + "\tMATCHED");
			return match;
		}
		DtrfDbg.println(this, indent + "\tNO MATCH");
		return null;
	}
A class that describes Decompiler variables and the fields that they may access.
Ghidra/Features/DecompilerDependent/src/main/java/ghidra/app/extension/datatype/finder/VariableAccessDR.java