I noticed while looking at this that the doc for this function is pretty wrong, as a result of evolution.  It talks about a "specified degree" even though there isn't one.  Up to you if you want to consider that part of this pull request.