SharePoint: Get Publishing Pages from inside folders

I had few folders in a pages library which contained pages inside them. PublishingWeb.GetPublishingPages() only gets pages present in the root folder and not form the other folders present in library. However, there is another overload of GetPublishingPages() which takes SPQuery as a parameter. Recursive scope can be defined in the query to get pages from folders as well. Here is an example:
using (SPSite site = new SPSite("http://aissp2013")) 
{ 
    SPWeb web = site.RootWeb; 
    PublishingWeb pubWeb = PublishingWeb.GetPublishingWeb(web); 
    SPQuery query = new SPQuery(); 
    query.ViewAttributes = "Scope=\"Recursive\""; 
    PublishingPageCollection pages = pubWeb.GetPublishingPages(query); 
    int count = pages.Count; 
    foreach (var page in pages) 
    { 
        // Some code implementation here
    } 
}
profile for Nadeem Yousuf at SharePoint Stack Exchange, Q&A for SharePoint enthusiasts

+