Lean4
/-- Retrieves an element uniquely determined by a `PosNum` from the tree,
taking the following path to get to the element:
- `bit0` - go to left child
- `bit1` - go to right child
- `PosNum.one` - retrieve from here -/
def get : PosNum → Tree α → Option α
| _, nil => none
| PosNum.one, node a _t₁ _t₂ => some a
| PosNum.bit0 n, node _a t₁ _t₂ => t₁.get n
| PosNum.bit1 n, node _a _t₁ t₂ => t₂.get n