Fix to nonrecursive paths

This runs very quickly and with low memory consumption, but I think it
has errors (see the lab notes.)