private static @Nullable Point getChildLocationRelativeToAncestor(@NotNull Component ancestor, @NotNull Component child) {
    int dx = 0, dy = 0;
    Component c = child;
    while (c != null && c != ancestor) {
      Point p = c.getLocation();
      dx += p.x;
      dy += p.y;
      c = child.getParent();
    }
    return c == ancestor ? new Point(dx, dy) : null;
  }
private static @Nullable Point getChildLocationRelativeToAncestor(@NotNull Component ancestor, @NotNull Component child)