fix(pages): memory leaks in large page trees

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

Fixes #6477
Merge pull request #6480 from hypeJunction/pages-fixes

fix(pages): use ElggBatch to avoid memory leaks