more robust checking of same type hierarchy