def count_instr_recursively(f, opname):
    count = 0
    for instr in dis.get_instructions(f):
        if (instr.opname == opname):
            count += 1
    if hasattr(f, '__code__'):
        f = f.__code__
    for c in f.co_consts:
        if hasattr(c, 'co_code'):
            count += count_instr_recursively(c, opname)
    return count
def count_instr_recursively(f, opname):
    count = 0
    for instr in dis.get_instructions(f):
        if (instr.opname == opname):
            count += 1
    if hasattr(f, '__code__'):
        f = f.__code__
    for c in f.co_consts:
        if hasattr(c, 'co_code'):
            count += count_instr_recursively(c, opname)
    return count