Adaptive Time Step - "If Not Converged" Command

Hello. I’m trying to implement a simple adaptive time step on a Newton solver. Is there a Fenics command for:

IF not converged after x iterations…

Many thanks!

See for instance: Custom Newton Solver problem with Dirichlet conditions - #5 by javijv4
You can then easily adapt the code to include an if statement

Thank you so much, I’ll look into that!