@classmethod
def __addToTree(cls, menu, item, checkFunction=None):
    """ Helper function to recursively add items to a menu.
        Add item (a dictionary that can contain more dictionaries) to menu
        If check function is added will use it to check if the value must be added.
        """
    children = item.pop('children', [])
    if checkFunction is not None:
        add = checkFunction(item)
        if not add:
            return
    subMenu = menu.addSubMenu(**item)
    for child in children:
        cls.__addToTree(subMenu, child, checkFunction)
    return subMenu
