public static function validateUnique($name, $function, $suffix = null)
    {
        $i = 1;
        $newName = $name;
        while (!call_user_func($function, $newName)) {
            if (!$suffix) {
                $newName = $name . ($i + 1);
            } elseif ($i == 1) {
                $newName = $name . $suffix;
            } else {
                $newName = $name . $suffix . $i;
            }
            $i++;
        }

        return $newName;
    }