Multistep mechanism of G-quadruplex resolution during DNA replication