public static MenuElement findMenuElement(final MenuElement root, final String text) {
        for (MenuElement item : root.getSubElements()) {
            if (item instanceof JMenu == true) {
                JMenu mItem = (JMenu) item;
                if (mItem.getSubElements().length > 0) {
                    MenuElement elem = findMenuElement(mItem, text);
                    if (elem != null)
                        return elem;
                }
                continue;
            }
            if (item instanceof JPopupMenu == true) {
                JPopupMenu mItem = (JPopupMenu) item;
                if (mItem.getSubElements().length > 0) {
                    MenuElement elem = findMenuElement(mItem, text);
                    if (elem != null)
                        return elem;
                }
                continue;
            }

            if (item instanceof JMenuItem == false)
                continue;
            JMenuItem mItem = (JMenuItem) item;
            if (mItem.getText().equals(text) == true)
                return mItem;
        }
        return null;
    }