For fixed constants $p, q \in \mathbb{R}$, define the function $f: \mathbb{Z}^+ \to \mathbb{R}$ on the even positive integers by $$ f(x) = \prod_{i = 1}^m \left( p^{2^{k_i}} + q^{2^{k_i}} \right) ,$$ where $x = 2^{k_1} + \dots + 2^{k_m}$ and $k_1 > \dots > k_m > 0$, i.e., the binary representation of $x$. I want to show that $$ \sum_{n~\geq~0,~n \text{ even}} f(n) = \prod_{k \geq 1} \left( 1 + p^{2^k} + q^{2^k} \right) .$$ I roughly see why this is true: if you expand the latter product while keeping the $\left( p^{2^k} + q^{2^k} \right)$ terms together, you enumerate all the values of $f$ in binary. But, this feels like a cheap argument because I know I should really be treating the infinite product as a limit, and so you can't expand as I just did (moreover, it leads to the problem of should $1$ be left in the expansion, which it absolutely shouldn't).
Is this a non-rigorous argument, and if so, what would a formal one look like?