pagesTree refactor