protected static function removeByIndex($array, $indices)
    {
        // Create a reference to the original array.
        $a = &$array;
        // Count all passed indices, remove one because arrays are zero based.
        $c = count($indices) - 1;
        // Iterate over all passed indices.
        for ($i = 0; $i <= $c; ++$i) {
            // Make sure the index to go down for deletion actually exists.
            if (!array_key_exists($indices[$i], $a)) {
                throw new ArrayStorageException(
                    sprintf('"%s" does not exist in storage object', $indices[$i])
                );
            }
            // This is the target if we reached the last index that was passed.
            if ($i === $c) {
                unset($a[$indices[$i]]);
            } elseif (is_array($a[$indices[$i]])) {
                // Make sure we have an array to go further down.
                $a = &$a[$indices[$i]];
            } else {
                throw new ArrayStorageException(
                    sprintf('"%s" does not exist in storage object', $indices[$i])
                );
            }
        }
        return $array;
    }