@staticmethod
def _for_each_option_group(callback, options):
    """
        Given set of options, call a callback for each option group.

        :param options: List of option groups, or a dict listing options directly.
        :param callable callback: Must accept at least 2 parameters: ``options`` (``dict``), listing options
            in the group, and keyword parameter ``group_name`` (``str``), which is set to group name when
            the ``options`` defines an option group.
        """
    if isinstance(options, dict):
        callback(options)
    elif isinstance(options, (list, tuple)):
        for group in options:
            if isinstance(group, dict):
                callback(group)
            else:
                group_name, group_options = group
                callback(group_options, group_name=group_name)
