def METHOD_NAME(
    self, to_substitute: str, context: str = "", max_iterations: int = 1000
) -> str:
    """Perform a search-replace on the first argument
    The `context` argument may be used to add information to warnings
    emitted during subsitution.
    """
    substituted_string = to_substitute
    for _ in range(max_iterations):
        substituted_tmp_string = _replace_strings(self, substituted_string)
        if substituted_tmp_string is None:
            break
        substituted_string = substituted_tmp_string
    else:
        warning_message = (
            "Reached max iterations while trying to resolve defines in the "
            f"string '{to_substitute}' - after iteratively applying substitutions "
            f"given by defines, we ended up with the string '{substituted_string}'"
        )
        if context:
            warning_message += f" - context was {context}"
        logger.warning(warning_message)
    return substituted_string