You should never rely on checks like this, and because JavaScript is slow, never retrieve an item multiple times.  This function should be rewritten as
```
var id;
var idNode = node.attributes.id;
if(typeof idNode !== 'undefined') {
    id = idNode.value;
} else {
    id = createGuid();
}
return id;
```