function findReference(_, variable) {
    // remove 'value' to access the whole token object
    variable = variable.trim().replace(`.${usesDtcg ? '$' : ''}value`, '');

    // Find what the value is referencing
    const pathName = getPathFromName(variable);

    let ref = getValueByPath(pathName, tokens);

    let unfilteredWarning;
    if (ref === undefined && unfilteredTokens) {
      // warn the user about this
      if (warnImmediately) {
        unfilteredWarning = `Filtered out token references were found: ${variable}`;
      } else {
        // we collect the warning and warn later in the process
        GroupMessages.add(FILTER_WARNINGS, variable);
      }
      // fall back on unfilteredTokens as it is unfiltered
      ref = getValueByPath(pathName, unfilteredTokens);
    }

    if (ref !== undefined) {
      references.push({ ...ref, ref: pathName });
      // not undefined anymore which means that if unfilteredWarning was set earlier,
      // the missing ref is due to it being filtered out
      if (unfilteredWarning) {
        console.warn(unfilteredWarning);
      }
    } else {
      const errMessage = `Tries to reference ${variable}, which is not defined.`;
      if (warnImmediately) {
        throw new Error(errMessage);
      }
    }
    return '';
  }
this will update the references array with the referenced tokens it finds.
@param {string} _
@param {string} variable