List<PyExpressionStatement> (@NotNull PyAssignmentStatement assignment) { ArrayList<PyExpressionStatement> result = new ArrayList<>(); final PyExpression[] targets = assignment.getTargets(); assert targets.length == 1; final PyExpression target = targets[0]; final String name = target.getName(); assert name != null; PyStatement expressionStatement = PsiTreeUtil.getNextSiblingOfType(assignment, PyStatement.class); while (expressionStatement instanceof PyExpressionStatement) { final PyExpression statement = ((PyExpressionStatement)expressionStatement).getExpression(); if (!(statement instanceof PyCallExpression callExpression)) break; final PyExpression callee = callExpression.getCallee(); if (!(callee instanceof PyQualifiedExpression)) break; final PyExpression qualifier = ((PyQualifiedExpression)callee).getQualifier(); if (qualifier == null || !name.equals(qualifier.getText())) break; final String funcName = ((PyQualifiedExpression)callee).getReferencedName(); if (!"append".equals(funcName)) break; final PyArgumentList argList = callExpression.getArgumentList(); if (argList != null) { // TODO Use proper resolve to the original target here if (ContainerUtil.exists(argList.getArguments(), argument -> argument.getText().equals(name))) { break; } result.add((PyExpressionStatement)expressionStatement); } expressionStatement = PsiTreeUtil.getNextSiblingOfType(expressionStatement, PyStatement.class); } return result; }