function wp2grav_get_pages($args, $post_type = 'page')
{
    $defaults = array("post_type" => $post_type, "parent" => "0", "post_parent" => "0", "numberposts" => "-1", "orderby" => "menu_order", "order" => "ASC", "post_status" => "any", "suppress_filters" => 0);
    $args = wp_parse_args($args, $defaults);
    // contains all page ids as keys and their parent as the val
    $arr_all_pages_id_parent = wp2grav_content_tree::get_all_pages_id_parent($post_type);
    $pages = get_posts($args);
    $data_array = array();
    // go through pages
    foreach ($pages as $one_page) {
        // add num of children to the title
        // @done: this is still being done for each page, even if it does not have children. can we check if it has before?
        // we could fetch all pages once and store them in an array and then just check if the array has our id in it. yeah. let's do that.
        // if our page id exists in $arr_all_pages_id_parent and has a value
        // so result is from 690 queries > 474 = 216 queries less. still many..
        // from 474 to 259 = 215 less
        // so total from 690 to 259 = 431 queries less! grrroooovy
        if (in_array($one_page->ID, $arr_all_pages_id_parent)) {
            $post_children = get_children(array("post_parent" => $one_page->ID, "post_type" => $post_type));
            $post_children_count = sizeof($post_children);
        } else {
            $post_children_count = 0;
        }
        $child_data_array = null;
        if ($post_children_count > 0) {
            $args_childs = $args;
            $args_childs["parent"] = $one_page->ID;
            $args_childs["post_parent"] = $one_page->ID;
            $args_childs["child_of"] = $one_page->ID;
            // can we run this only if the page actually has children? is there a property in the result of get_children for this?
            // eh, you moron, we already got that info in $post_children_count!
            // so result is from 690 queries > 474 = 216 queries less. still many..
            $child_data_array = wp2grav_get_pages($args_childs, $post_type);
        }
        $data_array[] = array('page' => $one_page, 'subtree' => $child_data_array);
    }
    return $data_array;
}