static function simpleXmlToStdClass(SimpleXMLElement &$source)
  {
    $res = new StdClass;
    $children = false;
    foreach ($source as $key => $value) {
      if (isset($res->$key)) {
        if (!is_array($res->$key)) {
          $res->$key = array($res->$key);
        }
        $ref = &$res->$key;
        $ref[] = CPS_Response::simpleXmlToStdClass($value);
      } else {
        $res->$key = CPS_Response::simpleXmlToStdClass($value);
      }
      $children = true;
    }
    if (!$children)
      return (string)$source;
    return $res;
  }