PyExpression[] (@NotNull final PyExpression expression) { if (expression instanceof PyListLiteralExpression list) { return list.getElements(); } else if (expression instanceof PyTupleExpression tuple) { return tuple.getElements(); } else if (expression instanceof PyStringLiteralExpression string) { String value = string.getStringValue(); // Strings might be packed as well as dicts, so we need to resolve somehow to string element. // But string element isn't PyExpression so I decided to resolve to PyStringLiteralExpression for // every string element PyExpression[] result = new PyExpression[value.length()]; Arrays.fill(result, expression); return result; } return PyExpression.EMPTY_ARRAY; }