Hamiltonian and non‐Hamiltonian perturbation theory for nearly periodic motion