Could this function just be `return node.parent && node.parent.tagID`? (Or do you want to make sure that `null` always gets returned and never `undefined`?)