private function getOptionsFromElement(Element $element) { if (!$element->hasChildren()) { return true; } $result = []; foreach ($element as $child) { if ($child instanceof Text) { return $child->getText(); } if ($child instanceof Element) { $result[$child->getName()] = $this->getOptionsFromElement($child); } } return $result; }