class TooltipLabel extends JBLabel {

  @VisibleForTesting // Unit testing Swing focus is not trivial, test this directly instead
  @Nullable
  String getTooltip(@NotNull Component component) {
    if (!isInScope(component)) {
      return null;
    }

    String tooltip = null;
    TreeWalker treeWalker = new TreeWalker(component);
    for (Component c : treeWalker.ancestors()) {
      if (c instanceof JComponent) {
        JComponent jc = (JComponent)c;
        tooltip = jc.getToolTipText();
      }

      if (c == myScope || tooltip != null) {
        break;
      }
    }

    return tooltip;
  }

  public  TooltipLabel();

}