[TASK] refactor pagetree with foreach element