Hierarchical querying, an interesting way of retrieving data for analysis, transforming and reporting. In latest version of CRM, we can use fetchxml to query and retrieve hierarchical data.
The hierarchical data retrieval in fetchxml can be achieved using following filter condition operators
Find all child account hierarchy for the parent account.
In the below fetchxml the highlighted operator called under will fetch all the accounts that are under the given accounts hierarchy.
Try all the above filter operators and also refer below MSDN article for more info and do not forget to go through restrictions.