Wrote the method to find the nodes within n hops