Wrote function to find depth of a node