code: def set_dict(dictionary, value, command='set', *keys):
      
  
      existing = dictionary
      for i in range(0, len(keys) - 1):
          if keys[i] in existing:
              existing = existing[keys[i]]
          else:
              existing[keys[i]] = existing.__class__()
              existing = existing[keys[i]]
      if command == 'set':
          existing[keys[len(keys) - 1]] = value
      elif command == 'append':
          if keys[len(keys) - 1] in existing:
              existing[keys[len(keys) - 1]].append(value)
          else:
              existing[keys[len(keys) - 1]] = [value]
      elif command == 'set_or_append':
          if keys[len(keys) - 1] in existing:
              if type(keys[len(keys) - 1]) == type([]):
                  existing[keys[len(keys) - 1]].append(value)
              else:
                  existing[keys[len(keys) - 1]] = [existing[keys[len(keys) - 1]], value]
          else:
              existing[keys[len(keys) - 1]] = value
      elif command == 'insert':
          if keys[len(keys) - 1] in existing:
              if not value in existing[keys[len(keys) - 1]]:
                  existing[keys[len(keys) - 1]].append(value)
          else:
              existing[keys[len(keys) - 1]] = [value]
docs: set_dict takes a dictionary, the value to
      enter into the dictionary, a command of what
      to do with the value, and a sequence of keys.
  
      d = {}
  
      set_dict(d,1,'append','level 1','level 2')
  
      -> d['level 1']['level 2'] = [1]
  
      set_dict(d,2,'append','level 1','level 2')
  
      -> d['level 1']['level 2'] = [1,2]