Trees: Refactoring retrieveTree method.