STS-3102: added additional optimization to the algorithm to lookup cached items in the inheritance graph first