General concept of a gradation slicing is used to analyze polynomial solutions of ordinary differential equations (ODE) with polynomial coefficients, Lψ = 0, where L = l p l (z)d l z , p l (z) are polynomials, z is a one-dimensional coordinate, and d z = d/dz. It is not required that ODE is ei-Fuchsian or (ii) leads to a usual Sturm-Liouville eigenvalue problem. General necessary and sufficient conditions for the existence of a polynomial solution are formulated involving constraint relations. The necessary condition for a polynomial solution of nth degree to exist forces energy to a nth baseline. Once the constraint relations on the nth baseline can be solved, a polynomial solution is in principle possible even in the absence of any underlying algebraic structure. The usefulness of theory is demonstrated on the examples of various Rabi models. For those models, a baseline is known as a Juddian baseline (e.g. in the case of the Rabi model the curve described by the nth energy level of a displaced harmonic oscillator with varying coupling g). The corresponding constraint relations are shown to (i) reproduce known constraint polynomials for the usual anddriven Rabi models and (ii) generate hitherto unknown constraint polynomials for the two-mode, two-photon, and generalized Rabi models, implying that the eigenvalues of corresponding polynomial eigenfunctions can be determined algebraically. Interestingly, the ODE of the above Rabi models are shown to be characterized, at least for some parameter range, by the same unique set of grading parameters.