If I have a rational function in $X$ and $Y$ and it can be written as both a polynomial in $Y$ with coefficients being rational functions in $X$ (that is, an element of $k(X)[Y]$) and as a polynomial in $X$ with coefficients being rational functions in $Y$ (that is, an element of $k(Y)[X]$), must the rational function in fact be a polynomial? Here $k$ is any field.
EDIT: More precisely, what I mean is this, say I have a rational function in $X$ and $Y$, that is something of the form $\frac{\text{polynomial in} \: X,Y}{\text{polynomial in} \: X,Y}$. I am able to express this is $p_0 + p_1Y + \dots + p_kY^k$ where the $p_i$ are rational functions in $X$ as well as $q_0 + q_1Y + \dots + q_lY^l$ where the $q_i$ are rational functions in $Y$. Must then the original rational function be able to be written as just a polynomial in $X$ and $Y$.
Thank you in advance.
Yes. Sketch: $k[X, Y]$ is a UFD, so it makes sense to ask that a fraction $\frac{p(x, y)}{q(x, y)} \in k(X, Y)$ be in lowest terms. The first condition implies that $q(x, y)$ is a polynomial in $x$ only and the second condition implies that $q(x, y)$ is a polynomial in $y$ only.