/// Recursively searches for the first `Witness::Known` node and returns its
/// path.
Recursively searches for the first `Witness::Known` node and returns its
path.
Recursively searches for the first ` Witness :: Known ` node and returns its path .
fn path_to_first_known(witness: &Witness) -> Option<Vec<Label>> {
    match witness {
        Witness::Known() => Some(vec![]),
        Witness::Fork {
            left_tree,
            right_tree,
        } => path_to_first_known(left_tree).or_else(|| path_to_first_known(right_tree)),
        Witness::Node { label, sub_witness } => path_to_first_known(sub_witness).map(|mut path| {
            path.insert(0, label.to_owned());
            path
        }),
        _ => None,
    }
}
fn path_to_first_known ( witness : & Witness ) -> Option < Vec < Label > > { match witness { Witness :: Known ( ) => Some ( vec ! [ ] ) , Witness :: Fork { left_tree , right_tree , } => path_to_first_known ( left_tree ) . or_else ( | | path_to_first_known ( right_tree ) ) , Witness :: Node { label , sub_witness } => path_to_first_known ( sub_witness ) . map ( | mut path | { path . insert ( 0 , label . to_owned ( ) ) ; path } ) , _ => None , } }
Recursively searches for the first `Witness::Known` node and returns its
path.
Recursively searches for the first ` Witness :: Known ` node and returns its path .
witness
&Witness