diff options
Diffstat (limited to 'src/vytree.ml')
-rw-r--r-- | src/vytree.ml | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/vytree.ml b/src/vytree.ml index 10ccf0e..3177e24 100644 --- a/src/vytree.ml +++ b/src/vytree.ml @@ -92,3 +92,14 @@ let rec get node path = | [] -> raise Empty_path | [name] -> find_or_fail node name | name :: names -> get (find_or_fail node name) names + +let get_existent_path node path = + let rec aux node path acc = + match path with + | [] -> acc + | name :: names -> + let child = find node name in + match child with + | None -> acc + | Some c -> aux c names (name :: acc) + in List.rev (aux node path []) |