def add2dict(dict, parent_list, key, value):
  """ Add a key/value pair to a dictionary; the pair is added following the
      hierarchy of 'parents' as define in the parent_list list. That is
      if parent list is: ['5', '1'], and key='k', value='v', then the new, 
      returned dictionary will have a value:
      dict['5']['1'][k] = v
  """
  d = dict
  for p in parent_list:
    if p not in d:
      d[p] = {}
    d = d[p]
  d[key] = value
  return dict