private static Component getDeepestComponentAt(@NotNull Component parent, int x, int y) {
    if (!parent.contains(x, y)) {
      // parent does not contain the specified location
      return null;
    }
    if (parent instanceof Container) {
      for (Component child : ((Container)parent).getComponents()) {
        if (child != null && child.isVisible()) {
          Component deepest;
          if (child instanceof Container) {
            deepest = getDeepestComponentAt(child, x - child.getX(), y - child.getY());
          }
          else {
            deepest = child.getComponentAt(x - child.getX(), y - child.getY());
          }
          if (deepest != null && deepest.isVisible()) {
            // the deepest component that contains the specified location
            return deepest;
          }
        }
      }
    }
    // do not allow returning visible glass pane without components
    return parent instanceof IdeGlassPane ? null : parent;
  }
private static Component getDeepestComponentAt(@NotNull Component parent, int x, int y)