I want to get sub folders of a root folder. And i am able to get it through the below code.
But has a issue when the sub folder has a sub folder in it and i over come it writing a second for each loop. But what if the second sub folder has a sub folder under it.
So there will be an infinte for each loop, so i have to overcome it.
Any help is worthfull.Thanks in advance. 

```
foreach (Folder.Folder folder in FolderService.Instance.GetSubFolders(userContext, folderID))
            {
                folderById.Add(folder.FolderID, folder);
                foreach (Folder.Folder sfolder in FolderService.Instance.GetSubFolders(userContext, folder.FolderID))
                {
                    folderById.Add(sfolder.FolderID, sfolder);
                }
            }

```