code: def _to_key_val_pairs(defs):
      
  
      if isinstance(defs, STRING_TYPES):
          # Convert 'a' to [('a', None)], or 'a.b.c' to [('a', 'b.c')]
          return [defs.split('.', 1) if '.' in defs else (defs, None)]
      else:
          pairs = []
  
          # Convert collections of strings or lists as above; break dicts into component items
          pairs.extend(p for s in defs if isinstance(s, STRING_TYPES) for p in _to_key_val_pairs(s))
          pairs.extend(p for l in defs if isinstance(l, list) for p in _to_key_val_pairs(l))
          pairs.extend(p for d in defs if isinstance(d, dict) for p in iteritems(d))
  
          return pairs
docs: Helper to split strings, lists and dicts into (current, value) tuples for accumulation