def nested_dict_get_path(key, var):
  """Searches a nested dictionary for a key and returns
  a list of strings designating the
  complete path to that key.

  Returns an empty list if key is not found.
  Warning: if key is in multiple nest levels,
  this will only return one of those values."""

  path = []
  if hasattr(var, 'iteritems'):
    for k, v in var.items():
      if k == key:
        path.append(k)
        break
      if isinstance(v, dict):
        local_path = [k]
        maybe_path = nested_dict_get_path(key, v)
        if maybe_path != []:
          local_path.extend(maybe_path)
          path.extend(local_path)
  return path