boolean (@Nullable Component child, @NotNull Component parent) { while (child != null && child != parent) { child = child instanceof JPopupMenu ? ((JPopupMenu)child).getInvoker() : child.getParent(); } return child == parent; }