Stochastic Calculus for Jump Processes: Squared Compound Poisson Compensated Stochastic Integral I'm reading these notes on stochastic calculus for jump processes which are great.
On page 670 of these notes, the author derives the expected value of the squared compound Poisson compensated stochastic integral.
Let $N_t$ be a Poisson process with intensity $\lambda$ and $Z$ a sequence of square-integrable random variables.
The process $Y_t$ is then given by the random sum $Y_t := Z_1 + Z_2 + \ldots + Z_{N_t} = \sum_{k=1}^{N_t} Z_k$.
In my understanding the Poisson process $N_t$ gives the jump times and the $Z_{N_t}$ is a random variable modelling how much we jump when $N_t=1$.
Let $\phi_{t}$ be a stochastic process adapted to the filtration generated by $Y_t$ admitting left limits $\phi_{t-} := \lim_{s \rightarrow t} \phi_s$.
My question concerns this expectation of the squared integral:
$$
\begin{align}
\mathbb{E}\left[ \left (\int_0^T \phi_{t-} \ (dY_t - \lambda \mathbb{E}[Z] dt) \right)^2 \right] = \lambda \mathbb{E}[|Z|^2] \mathbb{E} \left[ \int_0^T | \phi_{t-} |^2 \right]
\end{align}
$$
The author proves it by first separating the squared integral into
$$
\begin{align}
&\left(\int_0^T \phi_{t-} \ (dY_t - \lambda \mathbb{E}[Z] dt) \right)^2 \\
&= 2 \int_0^T \phi_{t-} \int_0^{t-} \phi_{s-} (dY_s - \lambda \mathbb{E}[Z] ds) (dY_t - \lambda \mathbb{E}[Z] dt) \\
& \quad + \int_0^T |\phi_{t-}|^2 |Z_{N_t}|^2 dN_t \quad \leftarrow \text{how did this arrive here?}
\end{align}
$$
where I have no clue where the last line came from.
I do see that use of the stochastic Fubini-type theorem while integrating over time.
Here is a screenshot of the authors notes while deriving the proof.
Any help or pointing me into a useful direction is greatly appreciated!
PS: I'm not a mathematician by training so apologies if I butchered the definitions. =)
 A: After going on a literature hunt I found an answer in this script on page 30.
The integral is decomposed into its off-diagonal terms (first row) and its diagonal/quadratic terms (second row).
The scaling factor of 2 occurs since we're integrating twice over the same domain.
Now to the quadratic term:
We are working with a compensated Poisson process which means that the process is centered around zero.
$$
\mathbb{E}[Y_t] = \lambda \mathbb{E}[Z] t
$$
Discretizing the integral gives us:
$$
\sum (\Delta \phi_{t-})^2 \Delta[Y_t - \lambda \mathbb{E}[Z]]\ \Delta[Y_t - \lambda \mathbb{E}[Z]]
$$
Substituting in the mean $\mathbb{E}[Y_t] = \mathbb{E}[Y_t]$ yields:
$$
\sum_t (\Delta \phi_{t-})^2 \Delta[Y_t - \mathbb{E}[Y_t]]^2
$$
where $ \Delta[Y_t - \mathbb{E}[Y_t]]^2$ is the diagonal term of the covariance for an infinitessimal small timestep $\Delta$.
We further know that the variance for a Poisson process $N_t$ of length $t$ is 
$$
\mathbb{V}[N_t] = \lambda t
$$
and that the variance of a scaled random variable $X$ is
$$
\mathbb{V}[aX] = a^2 \mathbb{V}[X].
$$
Since the jumps of the compensated Poisson process are modulated of sorts by the random variable $Z$ we obtain:
$$
\sum_t (\Delta \phi_{t-})^2 \Delta[Y_t - \mathbb{E}[Y_t]]^2 \\
= \sum_t (\Delta \phi_{t-})^2 \mathbb{V}[Z \Delta N_t] \\
= \sum_t (\Delta \phi_{t-})^2 Z^2 \mathbb{V}[\Delta N_t] \\
= \sum_t (\Delta \phi_{t-})^2 Z^2 \lambda \Delta t
$$
the continuous version of which is 
$$
\int \phi_{t-}^2 Z^2 \lambda dt
$$
