private FileNode CreateFile(string path, Func<FolderNode, string, FileNode> createStrategy) { FileNode resultNode = null; var currentNode = _rootNode; var parser = new PathParser(path); parser.WithEachButLastFileSystemNodeNameDo(folderName => currentNode = currentNode.CreateOrReuseFolderNode(folderName)); parser.WithLastFileSystemNodeNameDo(filename => resultNode = createStrategy(currentNode, filename)); return resultNode; }