def _check_in_loop(self, node, node_name):
_node = node.parent<EOL>while _node:<EOL><INDENT>if isinstance(_node, (astroid.For, astroid.While)):<EOL><INDENT>if node not in _node.orelse:<EOL><INDENT>return<EOL><DEDENT><DEDENT>if isinstance(_node, (astroid.ClassDef, astroid.FunctionDef)):<EOL><INDENT>break<EOL><DEDENT>if (<EOL>isinstance(_node, astroid.TryFinally)<EOL>and node in _node.finalbody<EOL>and isinstance(node, astroid.Continue)<EOL>):<EOL><INDENT>self.add_message("<STR_LIT>", node=node)<EOL><DEDENT>_node = _node.parent<EOL><DEDENT>self.add_message("<STR_LIT>", node=node, args=node_name)<EOL>
check that a node is inside a for or while loop