private static void restoreReference(@NotNull PsiElement sourceNode,
                                       @NotNull PsiElement targetNode,
                                       PsiElement @NotNull [] otherMovedElements) {
    try {
      if (sourceNode instanceof PyReferenceExpression) {
        doRestoreReference((PyReferenceExpression)sourceNode, targetNode, otherMovedElements);
      }
      else if (sourceNode instanceof PsiLanguageInjectionHost) {
        var injectionReferences = sourceNode.getCopyableUserData(INJECTION_REFERENCES);
        if (injectionReferences != null) {
          injectionReferences.forEach(expression -> doRestoreReference(expression, targetNode, otherMovedElements));
        }
      }
    }
    finally {
      sourceNode.putCopyableUserData(INJECTION_REFERENCES, null);
    }
  }
private static void restoreReference(@NotNull PsiElement sourceNode,
                                       @NotNull PsiElement targetNode,
                                       PsiElement @NotNull [] otherMovedElements)