This code will retrieve all the data in just one database query and remove duplicate entities on the client side so that operating on the results will be as expected (no duplicate rows as a result of left join query). DisplayContents simply iterates through the Department list and displays the children in a hierarchical tree using simple foreach nested loop.
And now the same thing, using QueryOver: