Component (@NotNull Component comp) { Component focused = getFocusOwner(); if (focused == null) { return null; } if (focused == comp || SwingUtilities.isDescendingFrom(focused, comp)) { return focused; } List<JBPopup> popups = AbstractPopup.getChildPopups(comp); for (JBPopup each : popups) { if (each.isFocused()) { return focused; } } return null; }