private async Task <CreateResult> CreateWithParents(CreateRequest request)
        {
            while (true)
            {
                var parentPath = ZooKeeperPath.GetParentPath(request.Path);
                if (parentPath == null)
                {
                    return(CreateResult.Unsuccessful(
                               ZooKeeperStatus.BadArguments,
                               request.Path,
                               new ArgumentException($"Can't get parent path for `{request.Path}`")));
                }

                var result = await CreateAsync(new CreateRequest(parentPath, CreateMode.Persistent)).ConfigureAwait(false);

                if (!result.IsSuccessful && result.Status != ZooKeeperStatus.NodeAlreadyExists)
                {
                    return(CreateResult.Unsuccessful(result.Status, request.Path, result.Exception));
                }

                result = await ExecuteOperation(new CreateOperation(request)).ConfigureAwait(false);

                if (result.Status != ZooKeeperStatus.NodeNotFound)
                {
                    return(result);
                }

                // Note(kungurtsev): someone has deleted our parent since we checked, create it again.
            }
        }
 public void GetParentPath_should_provide_correct_parent_paths(string path, string expectedParent)
 {
     ZooKeeperPath.GetParentPath(path).Should().Be(expectedParent);
 }