WordPress make Grandparent and great grandparent filterable in custom columns

So after reading through the codex, I came across the pre_get_posts hook, and I decided to try changing the query with it, which worked for me. Not sure if it is the best way though.

For anyone that is interested here is what I did:

add_action('pre_get_posts', 'get_grandchildren' );

function get_grandchildren() {
    if ( isset( $_GET['child_of'] ) ) {
        //Make a custom loop which selects the id of grandchildren of parents and puts them in an array and then
        set_query_var('post__in', $childrenArray );
    }
}

tech