Copy a properly formatted context into a mutable data structure.

def _copy_context_into_mutable(context):
    """Copy a properly formatted context into a mutable data structure.
    """
    def make_mutable(val):
        if isinstance(val, Mapping):
            return dict(val)
        else:
            return val

    if not isinstance(context, (str, Mapping)):
        try:
            return [make_mutable(val) for val in context]
        except TypeError:
            pass
    return make_mutable(context)