Why not:
```
if (!attributes["class"]) {
    return false;
}
```

That way you can get rid of pretty much all the if nesting here.