fix(pages): memory leaks in large page trees

Uses ElggBatch to avoid memory leaks in large page trees, fixes $container type check

Fixes #6477