Minor change: check type of index before using it

Indexing with an array and a list and a tuple are all different; this PR ensures that the correct behavior is used in `structure_at`.