void (@Nullable Window window, boolean modalOnly, boolean recursive) { if (window == null) return; Component component = window; while (component != null) { if (component instanceof Window) { boolean isClosed = closeWindow((Window)component, modalOnly); if (!isClosed) break; } component = recursive ? component.getParent() : null; } }