Better DOMDocument traversal