Factored out inheritance checking.