Window (Component component) { Window res = null; while (component != null) { if (component instanceof FloatingDecorator fd) { return fd; } Component parent = component.getParent(); if (component instanceof Window w) { if (ModalityHelper.isModalBlocked(w)) break; res = w; } component = parent; } return res; }