void (@NotNull final PyExpression arg) { final PyElementGenerator generator = new PyElementGeneratorImpl(getProject()); // Adds param to appropriate place final Deque<PyKeywordArgument> keywordArguments = getKeyWordArguments(); final Deque<PyExpression> parameters = getParameters(); if (keywordArguments.isEmpty() && parameters.isEmpty()) { generator.insertItemIntoListRemoveRedundantCommas(this, null, arg); return; } if (arg instanceof PyKeywordArgument) { if (parameters.isEmpty()) { generator.insertItemIntoListRemoveRedundantCommas(this, keywordArguments.getLast(), arg); } else { if (keywordArguments.isEmpty()) { generator.insertItemIntoListRemoveRedundantCommas(this, parameters.getLast(), arg); } else { generator.insertItemIntoListRemoveRedundantCommas(this, keywordArguments.getLast(), arg); } } } else { if (parameters.isEmpty()) { generator.insertItemIntoListRemoveRedundantCommas(this, null, arg); } else { generator.insertItemIntoListRemoveRedundantCommas(this, parameters.getLast(), arg); } } }