public function getLastChild() { if (($lastChild = $this->element->lastChild) === null) { return null; } elseif ($lastChild->nodeType === XML_ELEMENT_NODE) { return new self($lastChild); } else { $_lastChild = new self($lastChild); return $_lastChild->getPreviousSibling(); } }