Fetching leaf positions

I thought about this a moment and came to this not that efficient result
to get the leaf positions. I assume that this can be optimized, because
they array most likely never has 8 values stored (only case is a
leaf-only node). This is also an implementation that uses a while loop
that mimics a for loop. Maybe there is even more room for optimization.