public function getFirstChild() { if (($firstChild = $this->element->firstChild) === null) { return null; } elseif ($firstChild->nodeType === XML_ELEMENT_NODE) { return new self($firstChild); } else { $_firstChild = new self($firstChild); return $_firstChild->getNextSibling(); } }