If there is not first child, this will break. It is safer to do something like:

```javascript
var firstChild = parent.firstChild;
if (firstChild && firstChild.tagName !== 'SPAN') {
```