Usages (@NotNull PyFunction function, boolean skipReferencesToContainer) { final PyParameter keywordContainer = getKeywordContainer(function.getParameterList()); if (keywordContainer == null) return new Usages(false, new LinkedHashMap<>(), MultiMap.empty(), MultiMap.empty()); final Set<PyExpression> allReferences = new HashSet<>(); final Set<PyExpression> referencesAsOperandOrReceiver = new HashSet<>(); final LinkedHashMap<String, DefaultValue> names = new LinkedHashMap<>(); final MultiMap<String, PyCallExpression> calls = MultiMap.create(); final MultiMap<String, PySubscriptionExpression> subscriptions = MultiMap.create(); SyntaxTraverser .psiTraverser(function.getStatementList()) .forEach( e -> { if (!skipReferencesToContainer && e instanceof PyReferenceExpression && ((PyReferenceExpression)e).getReference().isReferenceTo(keywordContainer)) { allReferences.add((PyReferenceExpression)e); } else if (isKeywordContainerCall(e, keywordContainer)) { final PyCallExpression call = (PyCallExpression)e; referencesAsOperandOrReceiver.add(call.getReceiver(null)); final String name = getIndexValueToReplace(call); if (name != null) { names.merge(name, getDefaultKeyValue(call), DefaultValue::merge); calls.putValue(name, call); } } else if (isKeywordContainerSubscription(e, keywordContainer)) { final PySubscriptionExpression subscription = (PySubscriptionExpression)e; referencesAsOperandOrReceiver.add(subscription.getOperand()); final String name = getIndexValueToReplace(subscription); if (name != null) { names.merge(name, DefaultValue.noDefault(), DefaultValue::merge); subscriptions.putValue(name, subscription); } } } ); allReferences.removeAll(referencesAsOperandOrReceiver); return new Usages(!allReferences.isEmpty(), names, calls, subscriptions); }