public function addElement(AbstractClassContent $element, $index = null, $setMainNode = false, $contentSetPos = 0)
    {
        if (null !== $index) {
            $index = intval($index);
            if (!array_key_exists($index, $this->elements)) {
                throw new \InvalidArgumentException();
            }

            $this->elements[$index] = array(
                'content'               => $element,
                'set_main_node'         => (true === $setMainNode),
                'content_set_position'  => $contentSetPos,
            );
        } else {
            $this->pushElement($element, $setMainNode, $contentSetPos);
        }

        return $this;
    }