private function toArray(DOMElement $node)
    {
        $value = null;

        switch ($node->nodeName) {
            case 'array':
                $value = array();

                if ($node->hasChildNodes()) {
                    for ($i = 0; $i < $node->childNodes->length; $i++) {
                        /** @var $child DOMElement */
                        $child = $node->childNodes->item($i);

                        if ($child->hasAttribute('key')) {
                            $value[$child->getAttribute('key')] = $this->toArray($child);
                        } else {
                            $value[] = $this->toArray($child);
                        }
                    }
                }
                break;
            case 'bool':
                $value = (bool) $node->textContent;
                break;
            case 'float':
                $value = (float) $node->textContent;
                break;
            case 'int':
                $value = (int) $node->textContent;
                break;
            case 'str':
                $value = $node->textContent;
                break;
        }

        return $value;
    }