Convert balance node gathering to Cadence.

Create a function that gathers page count information. This is the first
step is to gather the left and the right using Cadence. The next step
will be to implement the loop using Cadence.

See #375.