URL Rewrite doesn’t work for nested pages

I have found my answer while searching. Thanks to this answer of @Milo: https://wordpress.stackexchange.com/a/50775/23214

pagename must include the full parent/child path. So, I had to change index.php?pagename=page-b... to index.php?pagename=page-a/page-b.... Changed it and works ok.

Here is the Full code:

add_filter( 'query_vars', 'wpse26388_query_vars' );
function wpse26388_query_vars( $query_vars ){
    $query_vars[] = 'var1';
    $query_vars[] = 'var2';
    $query_vars[] = 'var3';
    return $query_vars;
}

function wpse26388_rewrites_init(){
     add_rewrite_rule(
        'page-a/page-b/([0-9]+)/?$',
        'index.php?pagename=page-a/page-b&var1=$matches[1]',
        'top' );

    add_rewrite_rule(
        'page-a/page-b/([0-9]+)/([0-9]+)/?$',
        'index.php?pagename=page-a/page-b&var1=$matches[1]&var2=$matches[2]',
        'top' );

    add_rewrite_rule(
        'page-a/page-b/([0-9]+)/([0-9]+)/([0-9]+)/?$',
        'index.php?pagename=page-a/page-b&var1=$matches[1]&var2=$matches[2]&var3=$matches[3]',
        'top' );
}
add_action( 'init', 'wpse26388_rewrites_init' );