LeetCode 1379. Find a Corresponding Node of a Binary Tree in a Clone of That Tree in F#

This problem is not suit for F#. So I wrote modified version.

URL

leetcode.com/problems/find-a-corresponding-..

Code

github.com/syohex/dotnet-study/blob/master/..

type Tree =
    | Leaf
    | Node of int * Tree * Tree

let rec getTargetCopy (original: Tree) (cloned: Tree) (target: int) : Tree =
    match original, cloned with
    | Leaf, Leaf -> Leaf
    | Node (v1, left1, right1), Node (_, left2, right2) ->
        if v1 = target then
            cloned
        else
            match getTargetCopy left1 left2 target with
            | Node (_, _, _) as r -> r
            | Leaf -> getTargetCopy right1 right2 target
    | _, _ -> failwith "never reach here"