PyNamedParameter (@NotNull PyFunction function, @NotNull String referencedName) { for (PyFunction f = function; f != null; f = ObjectUtils.tryCast(ScopeUtil.getScopeOwner(f), PyFunction.class)) { PyNamedParameter element = f.getParameterList().findParameterByName(referencedName); if (element != null) { return element; } } return null; }