A structure detection algorithm for nonlinear dynamic rational models