def _check_nonlocal_and_global(self, node):
    'Check that a name is both nonlocal and global.'

    def same_scope(current):
        return (current.scope() is node)
    from_iter = itertools.chain.from_iterable
    nonlocals = set(from_iter((child.names for child in node.nodes_of_class(astroid.Nonlocal) if same_scope(child))))
    if (not nonlocals):
        return
    global_vars = set(from_iter((child.names for child in node.nodes_of_class(astroid.Global) if same_scope(child))))
    for name in nonlocals.intersection(global_vars):
        self.add_message('nonlocal-and-global', args=(name,), node=node)
Check that a name is both nonlocal and global.
def _check_nonlocal_and_global(self, node):
    

    def same_scope(current):
        return (current.scope() is node)
    from_iter = itertools.chain.from_iterable
    nonlocals = set(from_iter((child.names for child in node.nodes_of_class(astroid.Nonlocal) if same_scope(child))))
    if (not nonlocals):
        return
    global_vars = set(from_iter((child.names for child in node.nodes_of_class(astroid.Global) if same_scope(child))))
    for name in nonlocals.intersection(global_vars):
        self.add_message('nonlocal-and-global', args=(name,), node=node)