Checking no of folders inside a tree