Hybrid Sequence:
\FORMATTINGHACK{\needspace{3\baselineskip}} The starting point is $\L_{h-1}$.
Unroll the first iteration of the for-loop ($i=h$). Since $h \in \{1, \ldots, n\}$, the loop indeed has a first iteration. The change has no effect on the calling program.
Replace a redundant variable to clean things up.
We can rename $S_0$ and $S_1$ to $\prftable[P\|\bit0]$ and $\prftable[P\|\bit1]$. Then we can select the correct one using the entire $h$-bit prefix $P'$ of $X$, not just the $h$-th individual bit.
The library samples $\prftable[P]$ and then later (perhaps many times) computes $G(\prftable[P])$. We could instead compute $G(\prftable[P])$ immediately when $\prftable[P]$ is sampled and store the results for later.
The library assigns $\prftable[P]$ and $\prftable[P']$ at the same time, for all possible pairs $P$ and $P'$, so it doesn't matter which of $\prftable[P]$ or $\prftable[P']$ we use in the if-condition.
Now $\prftable[P]$ is used \emph{only} as the seed to the PRG, so we can apply the security of the PRG $G$. The standard three-hop maneuver is not shown.
The library simultaneously samples both $\prftable[P']$ and its ``sibling'': the same string as $P'$ with last bit flipped. But only one of these values is needed in a single call to $\prfquery$. \FORMATTINGHACK{\pagebreak} Since these values are sampled independently, we can sample only the needed one and defer the sibling value until later (if needed). The result is $\L_{h}$, which completes the proof.
$\L_{h-1}$
$\prfquery$($X$):
$P := \text{first } h-1 \text{ bits of } X$
if
$\prftable[P]$ undefined:
$\prftable[P']$ undefined:
$\prftable[P] \gets \bits^\secpar$
$R := \prftable[P]$
for $i = {}$
$h$ to $n$:
$h+1$ to $n$:
$S_0 \| S_1 := G(R)$
$R := S_{X[i]}$
return $R$