Print folder structure given a list of folders. Used scala to implement the algorithm