private @NotNull Component guessBestParentForSizeAdjustment() {
    if (this instanceof PopupToolbar) return this;
    Component result = ObjectUtils.chooseNotNull(getParent(), this);
    Dimension availSize = result.getSize();
    for (Component cur = result.getParent(); cur != null; cur = cur.getParent()) {
      if (cur instanceof JRootPane) break;
      if (cur instanceof JLayeredPane && cur.getParent() instanceof JRootPane) break;
      Dimension size = cur.getSize();
      if (myOrientation == SwingConstants.HORIZONTAL && size.height - availSize.height > 8 ||
          myOrientation == SwingConstants.VERTICAL && size.width - availSize.width > 8) {
        if (availSize.width == 0 && availSize.height == 0) result = cur;
        break;
      }
      result = cur;
      availSize = cur.getSize();
    }
    return result;
  }
private @NotNull Component guessBestParentForSizeAdjustment()