These branches could be recompressed again using "||" syntax to eliminate the "if (!element) {...}" block
i.e.,
if (ns !== null) {
element = node.getE...[0] || node.ownerDoc.createElementNS(); 
} else {
...
}