<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def namedtuple_asdict(obj):
 """ Serializing a nested namedtuple into a Python dict """

    if obj is None:
        return obj
    if hasattr(obj, "_asdict"):  # detect namedtuple
        return OrderedDict(zip(obj._fields, (namedtuple_asdict(item)
                                             for item in obj)))
    if isinstance(obj, str):  # iterables - strings
        return obj
    if hasattr(obj, "keys"):  # iterables - mapping
        return OrderedDict(zip(obj.keys(), (namedtuple_asdict(item)
                                            for item in obj.values())))
    if hasattr(obj, "__iter__"):  # iterables - sequence
        return type(obj)((namedtuple_asdict(item) for item in obj))
    # non-iterable cannot contain namedtuples
    return obj