private static function explodeKeys($keyPath)
    {
        $keys = explode('.', $keyPath);
        if (strpos($keyPath, '\\.') === false) {
            return array_filter($keys, function($elem) { return $elem !== ''; });
        }

        //
        // This is the slow path, where the keys contain escaped dots:
        //
        $joinNext = false;
        $result = array();
        $next = 0;
        foreach ($keys as $index => $key) {
            $len = strlen($key);
            if ($len === 0) {
                continue;
            }
            $endsWithBackslash = $key[$len - 1] === '\\';
            if ($joinNext) {
                $result[$next - 1] = sprintf("%s.%s", substr($result[$next - 1], 0, -1), $key);
                $joinNext = $endsWithBackslash;
                continue;
            }
            elseif ($endsWithBackslash) {
                $joinNext = true;
            }
            $result[$next] = $key;
            $next += 1;
        }

        return $result;
    }