Iterative degenerate perturbation theory