def freeze(obj):
if isinstance(obj, collections.Mapping):<EOL><INDENT>return FrozenDict({freeze(k): freeze(v) for k, v in six.iteritems(obj)})<EOL><DEDENT>elif isinstance(obj, list):<EOL><INDENT>return FrozenList([freeze(e) for e in obj])<EOL><DEDENT>else:<EOL><INDENT>return obj<EOL><DEDENT>
Transform tree of dict and list in read-only
    data structure.
    dict instances are transformed to FrozenDict, lists
    in FrozenList.