Respect tap directory layout when searching

This matches the logic in find_formula.