def METHOD_NAME(subst_list: SubstitutionList, string: str) -> Optional[str]:
    start = 0
    parts = []
    for match in _PATTERN.finditer(string):
        if (val := subst_list.get(match[0])) and val is not None:
            parts.append(string[start : match.start()])
            parts.append(val)
            start = match.end()
    if not parts:
        return None
    parts.append(string[start:])
    return "".join(parts)