get_page_hierarchy( WP_Post $pages, int $page_id )
Order the pages with children under parents in a flat list.
It uses auxiliary structure to hold parent-children relationships and runs in O(N) complexity
(WP_Post) (Required) Posts array (passed by reference).
(int) (Optional) Parent page ID. Default 0.
(string) Array of post names keyed by ID and arranged by hierarchy. Children immediately follow their parents.