Which partitions of $[0,1]$ are collection of level sets of a real continuous function? 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 continuous function $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.
 A: Any map $[0,1]\to[0,1]$ is a quotient map onto its image, and the image must be either a point or a closed interval.  So a partition comes from such a map iff the quotient of $[0,1]$ by the equivalence relation associated to the partition is homeomorphic to either a point or an interval.  In particular, given any characterization of an interval up to homeomorphism (among all spaces which are continuous images of an interval, which can themselves be nicely characterized if you assume they are Hausdorff), you get a characterization of such partitions.
Here is one such characterization, though maybe not a very easy one to apply.  It is known that any compact connected metrizable space with at most two non-cut-points is homeomorphic to either a point or $[0,1]$, and any Hausdorff quotient of $[0,1]$ is metrizable.  So a quotient of $[0,1]$ is homeomorphic to either a point or $[0,1]$ iff it is Hausdorff and has at most two non-cut-points.
These conditions can be stated explicitly in terms of the partition as follows.  Say that an element $A\in\mathscr{P}$ is a cut-set for $\mathscr{P}$ if $\mathscr{P}\setminus\{A\}$ can be split into two disjoint nonempty subpartitions $\mathscr{Q}$ and $\mathscr{R}$ such that $\bigcup\mathscr{Q}$ and $\bigcup\mathscr{R}$ are both open subsets of $[0,1]$.  Then a partition $\mathscr{P}$ is the level sets of a continuous map $[0,1]\to[0,1]$ if and only if:


*

*The equivalence relation associated to $\mathscr{P}$ is closed as a subset of $[0,1]\times[0,1]$, and

*All but at most two elements of $\mathscr{P}$ are cut-sets.


(Condition (1) is equivalent to the quotient being Hausdorff, and condition (2) is equivalent to the quotient having at most two non-cut-points.)
A: After reading Eric Wofsey's answer, I make the following observation (and I would like to know if the observation is accurate!).
Let $f:[0,1]\to[0,1]$ be continuous, and let $\mathscr{P}$ be the partition of $[0,1]$ arising from the level sets of $f$.  Let $A_+$ and $A_-$ denote the members of $\mathscr{P}$ on which $f$ takes its maximum and minimum values respectively.  Then for $A\in\mathscr{P}\setminus\{A_+,A_-\}$, $A$ may be seen to be a cut set by taking $\mathscr{Q}$ to be the collection of members of $\mathscr{P}$ contained in $f^{-1}(-\infty,f(A))$, and $\mathscr{R}$ to be the collection of members of $\mathscr{P}$ contained in $f^{-1}(f(A),\infty)$.
So certainly $\mathscr{P}$ can contain at most two non-cut sets, namely $A_+$ and $A_-$ (this is the contents of Eric Wofsey's condition (2)).  Conversely, it appears that $A_+$ and $A_-$ are non-cut sets.  It appears therefore that Eric Wofsey's solution can be simplified slightly as follows:

THEOREM: Let $\mathscr{P}$ be a partition of $[0,1]$.  The following are equivalent.
  
  
*
  
*There is a continuous function $f:[0,1]\to[0,1]$ whose collection of level curves is precisely $\mathscr{P}$.
  
*Each of the following two items obtain.
(1) The equivalence relation associated with $\mathscr{P}$ is closed in $[0,1]\times[0,1]$.
(2') Exactly two members of $\mathscr{P}$ are cut sets.

Additionally, if this is accurate, then Eric Wofsey's conditions (1) and (2) together imply the condition above (2').  Since these conditions are about partitions only, and do not prima facia have anything to do with continuous functions, it would be interesting to see an explanation of this implication which does not require a discussion of continuous functions.
A: Can't comment but feel obliged to point out a mistake (albeit one easy to fix) in the above answer.  The unit circle satisfies the given conditions---it has NO cut points.  To fix it replace "at most two" by "precisely two" and add non-degenerate (i.e., containing more than one point). This gives a complete chacterisation of spaces homeomorphic to $[0,1]$.  The degenerate case can easily be dealt with separately.  By the way, you can replace the metric condition by "regular and second countable"---not particularly relevant to your question, perhaps, but it gives a more satisfying characterisation in that it eliminates the use of the real numbers.
