Folding and misfolding pathways of G-quadruplex DNA