If this isn't clear, by doing this I can create one 3 or 4-dimensional array, then test against all lower dimensions by progressively removing the last axis.

This does some weird things in python 2.6 so I wrap it in a try...except block for safety.