A recursive solution is the simplest to implement.

Pseudocode for finding depth of tree branch:


public int depth(Node node)

local_depth = 0
If node doesn't exist:
return local_depth