public static void updateComponentTree(
            Component root, ComponentUpdater updater) {
        updater.update(root);

        if (root instanceof JComponent) {
            JPopupMenu popupMenu = ((JComponent) root).getComponentPopupMenu();
            if (popupMenu != null) {
                updateComponentTree(popupMenu, updater);
            }
        }

        Component[] children = null;
        if (root instanceof JMenu) {
            children = ((JMenu) root).getMenuComponents();
        } else if (root instanceof Container) {
            children = ((Container) root).getComponents();
        }
        if (children != null) {
            for (Component child : children) {
                updateComponentTree(child, updater);
            }
        }
    }