Make sure a node is an element node, not e.g. a comment/text node.