public function addChild(SVGNode $node, $index = null)
    {
        if ($node === $this || $node->parent === $this) {
            return $this;
        }

        if (isset($node->parent)) {
            $node->parent->removeChild($node);
        }

        $index = ($index !== null) ? $index : count($this->children);

        // insert and set new parent
        array_splice($this->children, $index, 0, array($node));
        $node->parent = $this;

        if ($node instanceof SVGStyle) {
            // if node is SVGStyle then add rules to container's style
            $this->addContainerStyle($node);
        }

        return $this;
    }