Author here, thanks for reading through the paper.
I think the confusion is because I wrote the pseudocode in a functional programming style so there are a few keywords being used which are causing confusion. ( Which i mentioned in the paper. )
The insert function uses the left.key and right.key to calculate the minimum distance for the key to be inserted.
And there is a cond statement which will execute only of the conditions.
And the pseudocode I wrote was in a functional programming style so the arguments in both the functions are same, just the name of the last argument is different, i.e root and leaf as I wanted to imply pattern matching happens.
The interesting part of the paper is that it outlines a new way to create a Sparse merkle tree, which inherently becomes ordered due to the insertion algorithm used. This ordered property is exploited to find the non-membership proof in a new way which does not require empty hashes and is compact. History independence also follows from the insertion algorithm used.
I'll be releasing an implementation for this paper soon so the proofs can be checked empirically as well.