Iterate over nested lists and dictionaries
===

I need to iterate over nested lists and dictionaries and replace every integer trough an hex string. Such an element could for example look like this:
<!-- language: lang-py -->

    element = {'Request': [16, 2], 'Params': ['Typetext', [16, 2], 2], 'Service': 'Servicetext', 'Responses': [{'State': 'Positive', 'PDU': [80, 2, 0]}, {}]}

After after applying the function, it should look like this:
<!-- language: lang-py -->

    element = {'Request': ['0x10', '0x02'], 'Params': ['Typetext', ['0x10', '0x02'], '0x02'], 'Service': 'Servicetext', 'Responses': [{'State': 'Positive', 'PDU': ['0x50', '0x02', '0x00']}, {}]}

I've already found a function, to iterate over such nested iterables http://code.activestate.com/recipes/577982-recursively-walk-python-objects/. Adapted to python 2.5 this function looks like this:
<!-- language: lang-py -->

    string_types = (str, unicode)
    iteritems = lambda mapping: getattr(mapping, 'iteritems', mapping.items)()
    
    def objwalk(obj, path=(), memo=None):
        if memo is None:
            memo = set()
        iterator = None
        if isinstance(obj, dict):
            iterator = iteritems
        elif isinstance(obj, (list, set)) and not isinstance(obj, string_types):
            iterator = enumerate
        if iterator:
            if id(obj) not in memo:
                memo.add(id(obj))
                for path_component, value in iterator(obj):
                    for result in objwalk(value, path + (path_component,), memo):
                        yield result
                memo.remove(id(obj))
        else:
            yield path, obj

But the problem with this function is, that it returns tuple elements. And those can't be edited.
Can you help me to implement a function I need?

Best regards
wewa 