private function processElement(array $element, $class, BaseElement $parent, $replaceAttribute = null)
    {
        $apiElement = new $class($element);

        if (!$replaceAttribute) {
            $parent->addContentElement($apiElement);
        } else {
            $parent->replaceAttributeWithElement($replaceAttribute, $apiElement);
        }

        if (isset($element['attributes'])) {
            foreach ($element['attributes'] as $attributeName => $attributeValue) {
                if (!isset($this->elementMap[$attributeName])) {
                    continue;
                }

                $this->processElement(
                    $attributeValue,
                    $this->elementMap[$attributeName],
                    $apiElement,
                    $attributeName
                );
            }
        }

        if (!isset($element['content'])) {
            return;
        }

        if (!is_array($element['content'])) {
            return;
        }

        $this->iterate($element['content'], $apiElement);
    }