This does a slightly different thing than njsmith's proposal. A more accurate way would be: find the leftmost (non-null) item that is not a subclass of the (non-null) items on its right.