In Andrey Gogolev's answer the following assertion appears:

"Now consider any maximal interval $(c,e)\subset ((a,b)-X)$. Recall that $f$ is a polynomial of some degree $d$ on $(c,e)$."

I see that for each $x\in (c,e)$ there is an interval $(c1,e1)\subset (c,e)$ with $x\in (c1,e1)$ and for which $f$ is a polynomial on $(c1,e1)$.  How do we know that these possibly different $f$s are indeed the restriction of some single polynomial $f$ defined on all of $(c,e)$?