void (@NotNull PsiElement scopeAncestor, @NotNull BiFunction<PsiElement, RefutablePatternInstruction, PsiElement> newScopeProvider) { retargetOutgoingEdges(scopeAncestor, (pendingScope, instruction) -> { if (instruction instanceof RefutablePatternInstruction) { return newScopeProvider.apply(pendingScope, (RefutablePatternInstruction)instruction); } return pendingScope; }); }