def METHOD_NAME(tree, level, pid, cmd):
    logger.info('TRex subprocess level: %s, pid: %s, cmd: %s' % (level, pid, cmd))
    if level > 4:
        logger.warn('Process tree is too deep (level %s)' % level)
        return
    gdb_cmd = 'gdb --pid %s --eval bt --batch' % pid
    output = subprocess.check_output(shlex.split(gdb_cmd), stderr = subprocess.STDOUT, universal_newlines = True)
    logger.info('BT of subprocess:\n%s' % output)
    for child_pid, child_cmd in tree.get(pid, []):
        METHOD_NAME(tree, level + 1, child_pid, child_cmd)