  We study the functional equation $A\circ X=X\circ B$, where $A,$ $B$, and $X$
are polynomials over $\mathbb C$. Using previous results of the author about
polynomials sharing preimages of compact sets, we show that for given $B$ its
solutions may be described in terms of the filled-in Julia set of $B$. On this
base, we prove a number of results describing a general structure of solutions.
The results obtained imply in particular the result of Medvedev and Scanlon
about invariant curves of maps $F:\,\mathbb C^2 \rightarrow \mathbb C^2$ of the
form $(x,y)\rightarrow (f(x),f(y))$, where $f$ is a polynomial, and a version
of the result of Zieve and M\"uller about decompositions of iterations of a
polynomial.
