There’s more…

Conditional statements are usually part of flow control statements, which include also iterations.

While iterating is not directly supported by psql, a similar effect can be achieved in other ways. For instance:

SELECT /* add a termination condition as appropriate */ AS do_loop
\gset
\if do_loop
\ir file.sql
\endif