code: def _add_value_to_dict_bf(d, k, v):
      
      prev = d.get(k)
      if prev is None:
          d[k] = v
      elif isinstance(prev, list):
          if isinstance(v, list):
              prev.extend(v)
          else:
              prev.append(v)
      else:
          if isinstance(v, list):
              x = [prev]
              x.extend(v)
              d[k] = x
          else:
              d[k] = [prev, v]
docs: Adds the `k`->`v` mapping to `d`, but if a previous element exists it changes
      the value of for the key to list.
  
      This is used in the BadgerFish mapping convention.
  
      This is a simple multi-dict that is only suitable when you know that you'll never
      store a list or `None` as a value in the dict.