/**
  * Find the child node matching the given node under the specified parent.
  * UNSAFE: may return nodes marked as _alteration="removed"
  * @param DOMNode $oParent
  * @param MFElement $oRefNode
  * @param string $sSearchId
  * @throws Exception
  */
 public static function _FindNode(DOMNode $oParent, MFElement $oRefNode, $sSearchId = null)
 {
     $oRes = null;
     if ($oParent instanceof DOMDocument) {
         $oDoc = $oParent->firstChild->ownerDocument;
         $oRoot = $oParent;
     } else {
         $oDoc = $oParent->ownerDocument;
         $oRoot = $oParent;
     }
     $oXPath = new DOMXPath($oDoc);
     if ($oRefNode->hasAttribute('id')) {
         // Find the first element having the same tag name and id
         if (!$sSearchId) {
             $sSearchId = $oRefNode->getAttribute('id');
         }
         $sXPath = './' . $oRefNode->tagName . "[@id='{$sSearchId}']";
         $oRes = $oXPath->query($sXPath, $oRoot)->item(0);
     } else {
         // Get the first one having the same tag name (ignore others)
         $sXPath = './' . $oRefNode->tagName;
         $oRes = $oXPath->query($sXPath, $oRoot)->item(0);
     }
     return $oRes;
 }