Peeling the longest: A simple generalized curve reconstruction algorithm