Extract implementation of `which` as `candidate`.

Extract for the sake of testing. Proof will be composed of multiple
files and not split up into a million modules to manage.

Closes #235.