I don't want to rely on a nodeName/tagName check, since it's relevant to the operation. This would be more appropriate:

```js
function getMessageId(target) {
  var node = target;
  do {
    if (node.dataset && node.dataset.messageId) {
      return +node.dataset.messageId;
    }
  } while (node = node.parentNode);

  return null;
}
```

Defined outside of `ThreadUI.handleEvent` of course