It seems like `$theme_obj->exists()` is checked more times than needed in this block of `if`s.