Fix iterations up the inheritance tree in objects

This fixes A bug I introduced into the code while fixing other stuff.