Recursive algorithm to traverse river networks (HYDRO1k format) and analyze their structure