private static @Nullable Project getProject(@Nullable Window window) {
    // A window may be not an IdeFrame itself, but owned by an IdeFrame, e.g., FloatingDecorator.
    var maybeIdeFrame = window;
    while (maybeIdeFrame != null) {
      if (maybeIdeFrame instanceof IdeFrame ideFrame) {
        return ideFrame.getProject();
      }
      maybeIdeFrame = maybeIdeFrame.getOwner();
    }
    return null;
  }
private static @Nullable Project getProject(@Nullable Window window)