static List <NodePath> getPathHierarchy(string path, List <NodePath> lst) { List <string> pl = new List <string>(path.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries)); if (pl.Count > 0) { lst.Add(new NodePath() { path = path, name = pl[pl.Count - 1] }); pl.RemoveAt(pl.Count - 1); string joined = TreeNode.listToPath(pl); getPathHierarchy(joined, lst); } return(lst); }