protected function recurseToArray($object)
    {
        if (is_scalar($object)) {
            return $object;
        }
        $array = (array)$object;
        foreach ($array as &$value) {
            if (!is_scalar(($value))) {
                $value = $this->recurseToArray($value);
                continue;
            }
        }
        return $array;
    }