private static @Nullable JRootPane findMainRootPane(@Nullable Component component) {
    while (component != null) {
      Container parent = component.getParent();
      if (parent == null) {
        return component instanceof RootPaneContainer ? ((RootPaneContainer)component).getRootPane() : null;
      }
      component = parent;
    }
    return null;
  }
private static @Nullable JRootPane findMainRootPane(@Nullable Component component)