@staticmethod
def cached_surrogate(cache, name_string, replacement_generator):
    """Generate a new surrogate for the given name or use an existing one if it already exist.

        Parameters
        ----------
        cache : dict(str: str)
            Lookup table of already replaced names. Keys are original names and values are
            surrogates.
        name_string : str
            The name to generate a replacement for
        replacement_generator : callable accepting `name_string`
            A callable that generates a new surrogate for `name_string`, in case no previous
            replacement exists.

        Returns
        -------
        str
            The surrogate name.

        """
    replacement = cache.get(name_string.lower(), None)
    if not replacement:
        replacement = replacement_generator(name_string)
        cache[name_string.lower()] = replacement
    return replacement
