iter version of longest path