def walk_code(co, _prefix=''):
    """
    Traverse a code object, finding all consts which are also code objects.

    Yields pairs of (name, code object).
    """
    name = _prefix + co.co_name
    yield name, co
    yield from chain.from_iterable(
        walk_code(c, _prefix=_extend_name(name, co))
        for c in co.co_consts
        if isinstance(c, CodeType)
    )