Corrected listLeafs() and added helper method.