Integrability of Hamiltonians with third‐ and fourth‐degree polynomial potentials