def copyoption(v):
    """Copies a dictionary and all its nested dictionaries and lists.

    Much like copy.deepcopy it provides a deep copy of a dictionary
    but instead of trying to copy everything it will only make a copy
    of dictionaries, lists, tuples and sets. All the containers typically
    used in configuration blueprints. All the other objects will be
    preserved by reference.
    """
    if isinstance(v, dict):
        return v.__class__((k, copyoption(v[k])) for k in v)
    elif isinstance(v, (list, set, tuple)):
        return v.__class__(copyoption(e) for e in v)
    else:
        # Preserve anything else as is.
        return v