public static function array_find_available_index($array, $seed = null)
    {
        if (!is_null($seed)) {
            $index = $seed;
        } else {
            $keys = array_keys($array);
            sort($keys);
            $index = array_pop($keys);
        }

        if (isset($array[$index])) {
            do {
                $index++;
            } while (isset($array[$index]));
        }

        return $index;
    }