boolean (PsiElement element) { if (!(element instanceof PyTargetExpression)) { return false; } // Handling of the star expressions PsiElement parent = element.getParent(); if (parent instanceof PyStarExpression){ element = parent; parent = element.getParent(); } if (parent instanceof PyTupleExpression tuple) { // if all the items of the tuple are unused, we still highlight all of them; if some are unused, we ignore for (PyExpression expression : tuple.getElements()) { if (expression instanceof PyStarExpression){ if (!myUnusedElements.contains(((PyStarExpression)expression).getExpression())){ return true; } } else if (!myUnusedElements.contains(expression)) { return true; } } } return false; }