import ast


def ast_contains_node(ast_node, nodetypes):
    """
    Check recursively if ast_node has a child of type nodetypes.
    nodetypes is either a type or a tuple of types.
    """
    ast_node = ast_node if type(ast_node) is list else [ast_node]
    for ast_root in ast_node:
        for node in ast.walk(ast_root):
            if isinstance(node, nodetypes):
                return True
    return False