protected static boolean expressionsIdenticallyDefined(PatternExpression a,
			PatternExpression b) {
		if (a.getClass() != b.getClass()) {
			return false;
		}
		if (a instanceof EndInstructionValue) {
			return true;
		}
		if (a instanceof Next2InstructionValue) {
			return true;
		}
		if (a instanceof StartInstructionValue) {
			return true;
		}
		if (a instanceof ConstantValue) {
			ConstantValue ca = (ConstantValue) a;
			ConstantValue cb = (ConstantValue) b;
			return ca.getValue() == cb.getValue();
		}
		if (a instanceof UnaryExpression) {
			UnaryExpression ua = (UnaryExpression) a;
			UnaryExpression ub = (UnaryExpression) b;
			return expressionsIdenticallyDefined(ua.getUnary(), ub.getUnary());
		}
		if (a instanceof BinaryExpression) {
			BinaryExpression ba = (BinaryExpression) a;
			BinaryExpression bb = (BinaryExpression) b;
			return expressionsIdenticallyDefined(ba.getLeft(), bb.getLeft()) &&
				expressionsIdenticallyDefined(ba.getRight(), bb.getRight());
		}
		if (a instanceof TokenField) {
			TokenField ta = (TokenField) a;
			TokenField tb = (TokenField) b;
			return ta.getBitStart() == tb.getBitStart() &&
				ta.getBitEnd() == tb.getBitEnd() &&
				ta.hasSignbit() == tb.hasSignbit();
		}
		if (a instanceof ContextField) {
			ContextField ca = (ContextField) a;
			ContextField cb = (ContextField) b;
			return ca.getStartBit() == cb.getStartBit() &&
				ca.getEndBit() == cb.getEndBit() &&
				ca.hasSignbit() == cb.hasSignbit();
		}
		if (a instanceof OperandValue) {
			OperandValue va = (OperandValue) a;
			OperandValue vb = (OperandValue) b;
			return va.getConstructor() == vb.getConstructor() &&
				va.getIndex() == vb.getIndex();
		}
		throw new AssertionError();
	}
Base implementation for expression matchers

@param <T> the type of expression matched
Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/app/plugin/assembler/sleigh/expr/match/AbstractExpressionMatcher.java