def find_assignment_in_context(variable, context):
    if isinstance(context, (ast.FunctionDef, ast.Module, ast.For, ast.While, ast.With, ast.If)):
        for node in reversed(list(ast.iter_child_nodes(context))):
            if isinstance(node, ast.Assign):
                if variable in (stringify(c) for c in node.targets):
                    return node
    if getattr(context, 'parent', None):
        return find_assignment_in_context(variable, context.parent)
    else:
        return None
dataset/ETHPy150Open uber/py-find-injection/py_find_injection/__init__.py/find_assignment_in_context/original