Optional<QuickSearchComponent> () { Component c = SoftReference.dereference(myFocusedBeforePopup); while (c != null) { if (c instanceof QuickSearchComponent) { return Optional.of((QuickSearchComponent)c); } c = c.getParent(); } return Optional.empty(); }