import ast


def is_name_in_ptree(name, ptree):
    """
    Return True if an ast.Name node with the given name as its id
    appears anywhere in the ptree, False otherwise
    """

    if not ptree:
        return False

    for node in ast.walk(ptree):
        if isinstance(node, ast.Name) and (node.id == name):
            return True

    return False