code: def _traverse_options(cls, obj, opt_type, opts, specs=None, keyfn=None, defaults=True):
          
          def lookup(x):
              """
              Looks up options for object, including plot defaults.
              keyfn determines returned key otherwise None key is used.
              """
              options = cls.lookup_options(x, opt_type)
              selected = {o: options.options[o]
                          for o in opts if o in options.options}
              if opt_type == 'plot' and defaults:
                  plot = Store.registry[cls.backend].get(type(x))
                  selected['defaults'] = {o: getattr(plot, o) for o in opts
                                          if o not in selected and hasattr(plot, o)}
              key = keyfn(x) if keyfn else None
              return (key, selected)
  
          # Traverse object and accumulate options by key
          traversed = obj.traverse(lookup, specs)
          options = defaultdict(lambda: defaultdict(list))
          default_opts = defaultdict(lambda: defaultdict(list))
          for key, opts in traversed:
              defaults = opts.pop('defaults', {})
              for opt, v in opts.items():
                  options[key][opt].append(v)
              for opt, v in defaults.items():
                  default_opts[key][opt].append(v)
  
          # Merge defaults into dictionary if not explicitly specified
          for key, opts in default_opts.items():
              for opt, v in opts.items():
                  if opt not in options[key]:
                      options[key][opt] = v
          return options if keyfn else options[None]
docs: Traverses the supplied object getting all options in opts for
          the specified opt_type and specs. Also takes into account the
          plotting class defaults for plot options. If a keyfn is
          supplied the returned options will be grouped by the returned
          keys.