public Function getReferencedFunction(Address address) {

		List<Address> referencesFrom = getReferenceFromAddresses(address);
		if (referencesFrom.size() != 1) {
			return null;
		}

		Address functionAddress = referencesFrom.get(0);

		Register lowBitCodeMode = currentProgram.getRegister("LowBitCodeMode");
		if (lowBitCodeMode != null) {
			long longValue = functionAddress.getOffset();
			longValue = longValue & ~0x1;
			functionAddress = functionAddress.getNewAddress(longValue);
		}

		Function function = getFunctionAt(functionAddress);
		if (function == null) {
			// try to create function
			function = createFunction(functionAddress, null);
			if (function == null) {
				return null;
			}
		}

		//if function is a thunk, get the thunked function					
		if (function.isThunk()) {
			Function thunkedFunction = function.getThunkedFunction(true);
			function = thunkedFunction;
		}
		return function;
	}
Method to get the function referenced at the given address if there is one. If the function
is a thunk, get the thunked function
@param address the given address
@return the (thunked if a thunk) function pointed to by the given address
Ghidra/Features/Decompiler/ghidra_scripts/classrecovery/ExtendedFlatProgramAPI.java