diff --git a/lib/SimpleSAML/Utilities.php b/lib/SimpleSAML/Utilities.php
index e0140a05687ca047426302c2f70e44d136f174dc..d2a0c1e07df48d07f820ac1a544f78fdcc4d9ad2 100644
--- a/lib/SimpleSAML/Utilities.php
+++ b/lib/SimpleSAML/Utilities.php
@@ -792,12 +792,16 @@ class SimpleSAML_Utilities {
 	 * @param $nsURI The namespaceURI the element should have.
 	 * @return TRUE if both namespace and localname matches, FALSE otherwise.
 	 */
-	public static function isDOMElementOfType($element, $name, $nsURI) {
-		assert('$element instanceof DOMElement');
+	public static function isDOMElementOfType(DOMNode $element, $name, $nsURI) {
 		assert('is_string($name)');
 		assert('is_string($nsURI)');
 		assert('strlen($nsURI) > 0');
 
+		if (!($element instanceof DOMElement)) {
+			/* Most likely a comment-node. */
+			return FALSE;
+		}
+
 		/* Check if the namespace is a shortcut, and expand it if it is. */
 		if($nsURI[0] == '@') {