private static Address getFlowingAddress(Program program, Instruction instr) {
		// check the refs to see if we can determine single flow destination
		Reference flowRef = null;
		Reference dataRef = null;
		for (Reference reference : instr.getReferencesFrom()) {
			RefType refType = reference.getReferenceType();
			if (refType.isData()) {
				dataRef = reference;
				continue;
			}
			if (!refType.isFlow()) {
				continue;
			}
			if (flowRef != null) {
				return null; // can't handle multiple flow-refs
			}
			flowRef = reference;
		}
		if (flowRef == null) {
			flowRef = dataRef;
		}
		if (flowRef != null) {
			RefType refType = flowRef.getReferenceType();
			if (refType.isData() || refType.isIndirect()) {
				// some references are labeled as INDIRECT which correspond to flow via a pointer
				Address toAddr = flowRef.getToAddress();
				Reference[] referencesFrom =
					program.getReferenceManager().getReferencesFrom(toAddr);
				if (referencesFrom.length == 1 &&
					(referencesFrom[0].getReferenceType() == RefType.DATA ||
						referencesFrom[0].isExternalReference())) {
					return referencesFrom[0].getToAddress();
				}
				return null; // can't use indirection in single 
			}
			return flowRef.getToAddress();
		}

		// it would have been a thunk, so return a bad address signaling it was a thunk
		return Address.NO_ADDRESS;
	}
Check if the setRegisters contains the varnode or any of its parents.
If a parent register has been set, then this varnode is set
Ghidra/Features/Base/src/main/java/ghidra/app/cmd/function/CreateThunkFunctionCmd.java