public Function getReferencedFunction(Address address, boolean getThunkedFunction)
			throws CancelledException {

		Reference[] referencesFrom = getReferencesFrom(address);

		if (referencesFrom.length == 0) {
			return null;
		}

		for (Reference referenceFrom : referencesFrom) {

			monitor.checkCancelled();

			Address referencedAddress = referenceFrom.getToAddress();
			if (referencedAddress == null) {
				continue;
			}

			Function function = getFunctionAt(referencedAddress);

			if (function == null) {
				continue;
			}

			if (!getThunkedFunction) {
				return function;
			}

			if (function.isThunk()) {
				function = function.getThunkedFunction(true);
			}
			return function;
		}

		return null;

	}
Method to get the function referenced at the given address
@param address the given address
@param getThunkedFunction if true and referenced function is a thunk, get the thunked function
@return the referenced function or null if no function is referenced
@throws CancelledException if cancelled
Ghidra/Features/Decompiler/ghidra_scripts/classrecovery/ExtendedFlatProgramAPI.java