Solution for Distances in Trees (nwck)