public static boolean isFocusAncestor(@NotNull Component component) {
    Component owner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
    if (owner == null) {
      return false;
    }
    if (SwingUtilities.isDescendingFrom(owner, component) || GraphicsEnvironment.isHeadless()) {
      return true;
    }

    while (component != null) {
      if (kindaHasFocus(component)) {
        return true;
      }
      component = component.getParent();
    }
    return false;
  }
public static boolean isFocusAncestor(@NotNull Component component)