BUG: Styler `cells_ids` fails on second render
issue #35588 addressed the issue of `cell_ids` failing.

This bug reports a failure on second render(), due to `ctx` object, as a `defaultdict`, having a key inserted when it is queried, which then impacts the programming logic the second time it is run.

The solution is to move the query within conditional a few lines above.
