@Internal
  public static @Nullable Window calcParentWindow(@Nullable Component parent, @Nullable Project project) {
    if (parent == null && project == null && !ApplicationManager.getApplication().isHeadlessEnvironment()) {
      parent = JOptionPane.getRootFrame();
    }
    if (parent != null) {
      return ComponentUtil.getWindow(parent);
    }
    Window parentWindow = WindowManager.getInstance().suggestParentWindow(project);
    return parentWindow != null ? parentWindow : WindowManagerEx.getInstanceEx().getMostRecentFocusedWindow();
  }
@Internal
  public static @Nullable Window calcParentWindow(@Nullable Component parent, @Nullable Project project)