Storing/restoring TreeCursor location efficiently

What’s the most efficient way to store/restore a TreeCursor location, i.e. which node it is pointing to? Is it to clone the node (const clone = cursor.node.cursor()) and work with the clone or something else?

If cloning is the way to go, all things considered (code size and interpreting time, execution time etc.) does anyone have a hunch on what is preferable - to clone the node or to navigate the original cursor back to the origin (I am guessing cloning)? I.e. (minimal examples to illustrate, real world would have a little more involved navigation)

function foo(cursor: TreeCursor): boolean {
    const clone = cursor.node.cursor()
    if (!(clone.firstChild() && clone.firstChild() && clone.nextSibling())) return false
    return do_something(clone)


function bar(cursor: TreeCursor): boolean {
    if (!cursor.firstChild()) return false
    let ok: boolean
    if (ok = cursor.firstChild()) {
        if (ok = cursor.nextSibling()) ok = do_something(cursor)
    return ok


Yes, .node.cursor() is how you clone a cursor, and cloning is cheap, so don’t bother moving a cursor back.