Given a graph rooted at a node (root), find maximum path length from root, and detect loops, if any.