private static function objectToArrayRecursive($object) {
        if (is_object($object))
            $object = (array) $object;
        if (is_array($object)) {
            $new = array();
            foreach ($object as $key => $val) {
                $new[$key] = self::objectToArrayRecursive($val);
            }
        } else
            $new = $object;
        return $new;
    }