Sum $1+(1+x)^2+(1+x+x^2)^2+\cdots+(1+x+x^2+\cdots+x^{N-2})^2 $ Is there a way to find the sum the following series:
$$1+(1+x)^2+(1+x+x^2)^2+\cdots+(1+x+x^2+\cdots+x^{N-2})^2 \text{ ?}$$
Any ideas ? Perhaps someone knows already the result..
Thank you in advance for your time.

Expanding on @AndréNicolas and @Vaneet, with little computation:
For convenience, we consider the sum until $n-1$ instead of $n-2$, and observe that we have a sum of squares of the partial sums of a geometric progression.
The denominators are all the same and we factor them out. The numerators are the differences $1-x^k$. By squaring, we will get terms $1$, $-2x^k$ and $x^{2k}$ for which the sums are easy.
Then the total is
$$\frac1{(1-x)^2}\left(n-2\frac{1-x^n}{1-x}+\frac{1-x^{2n}}{1-x^2}\right).$$
