docs: def iter_tasks(matrix, names, groups):
      """Iterate tasks."""
  
      # Build name index
      name_index = dict([(task.get('name', ''), index) for index, task in enumerate(matrix)])
  
      for index, task in enumerate(matrix):
          name = task.get('name', '')
          group = task.get('group', '')
          hidden = task.get('hidden', False)
          if names and name in names and index == name_index[name]:
              yield task
          elif groups and group in groups and not hidden:
              yield task
          elif not names and not groups and not hidden:
              yield task