Many search functions (dfs, dfwbs, ilds, rbs) share a lot of the same code and would benefit from being re-written in a more concise manner.