Let $f:[0,1]\to[0,1]$ be given. The level sets of $f$ (ie the collection of all sets of the form $\{x\in[0,1]:f(x)=y\}$, for each fixed $y\in[0,1]$) partition the domain of $f$. I am curious for set theoretic or point set topology criteria for which partitions of $[0,1]$ could be the level sets for a continuous function. That is, can someone fill in the blank in the following "theorem".

THEOREM: Let $\mathscr{P}$ be a partition of $[0,1]$. The following are equivalent.

There is some

continuousfunction $f:[0,1]\to[0,1]$ such that the collection of level sets of $f$ is exactly the partition $\mathscr{P}$.The partition $\mathscr{P}$ satisfies the property __________.

Even in the case where all the parts of $\mathscr{P}$ are finite, the picture seems pretty mysterious to me. For example, it is perfectly fine to have $\mathscr{P}$ consist of all pairs, and one singleton (for example the level sets of $f(x)=(x-1/2)^2$), but impossible for $\mathscr{P}$ to consist of all pairs except for two singletons. Can someone see a non-analytic over-arching principle which discerns the the first case from the second?

As a side note, the question can obviously be posed with the $[0,1]$ as domain and codomain replaced by arbitrary topological spaces $V$ and $W$.

EDIT: Fixed the counter-example above.