How to get the path depth of a data tree?

for example:


in this case,should be get “4”,
but how to get that number,by API or components all is ok,thank you!

Canvas%20at%2011%3B48%3B59

thankyou Dani,it works