import re


def compile_patterns_in_dictionary(dictionary):
    """
    Replace all strings in dictionary with compiled version of themselves and return dictionary.
    """

    for key, value in dictionary.items():
        if isinstance(value, str):
            dictionary[key] = re.compile(value)
        elif isinstance(value, dict):
            compile_patterns_in_dictionary(value)
    return dictionary