As I understand, a necessary and sufficient condition for a density matrix $P$ to be represented by a wavefunction $|\Psi\rangle$ is that it is idempotent, i.e. $P^2=P$. It is easy to see that if $P=|\Psi\rangle\langle \Psi|$ then $P$ is idempotent: $$ P^2=|\Psi\rangle\langle \Psi|\Psi\rangle\langle \Psi|=|\Psi\rangle\langle \Psi| $$ since by normalization $\langle \Psi|\Psi\rangle=1$. However, I have had trouble with the other direction - how can I show that if $P^2=P$ then $P=|\Psi\rangle\langle\Psi|$ for some $\Psi$?
I have been able to demonstrate that if $P^2=P$ then $$ P=\sum_{j} |\Psi_j\rangle\langle\Psi_j| $$ where the sum over $j$ has no more terms than the dimension of the density matrix $P$. My argument was analogous to the one found here. I suspect that I'm almost there - I think it's just a change of basis that I haven't seen yet. How can I complete this proof?