protected function findClosestItem($needle, $haystack)
    {
        $bestGuess = null;
        foreach ($haystack as $item) {
            if (preg_match('/^' . $needle . '/', $item)) {
                return $item;
            }
        }

        foreach ($haystack as $item) {
            if (preg_match('/' . $needle . '/', $item)) {
                return $item;
            }

            $score = levenshtein($needle, $item);

            if (!isset($bestScore) || $score < $bestScore) {
                $bestScore = $score;
                $bestGuess = $item;
            }
        }

        return $bestGuess;
    }