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); }