void (@NotNull List<PsiNamedElement> definitions, @NotNull TypeEvalContext typeEvalContext) { // Group overloads with their respective implementations List<List<PsiNamedElement>> grouped = StreamEx.of(definitions) .groupRuns((e1, e2) -> PyiUtil.isOverload(e1, typeEvalContext) && e2 instanceof PyFunction) .toList(); definitions.clear(); StreamEx.ofReversed(grouped) .flatCollection(Function.identity()) .into(definitions); }