def METHOD_NAME(key: bytes, has_hybrid_time: bool):
    inp = BinaryIO(BytesIO(key))
    value_type = ValueType.read(inp)
    if value_type != ValueType.kUInt16Hash:
        raise Exception('Missing key hash in {}, {}'.format(key, value_type))
    inp.read_int16()
    hash_components = []
    range_components = []
    for out in (hash_components, range_components):
        while True:
            value_type = ValueType.read(inp)
            if value_type == ValueType.kGroupEnd:
                break
            out.append(decode_key_entry(inp, value_type))
    sub_keys = []
    while True:
        value_type = ValueType.read(inp)
        if has_hybrid_time:
            if value_type == ValueType.kHybridTime:
                break
        else:
            if value_type is None:
                break
        sub_keys.append(decode_key_entry(inp, value_type))
    doc_ht = None
    if has_hybrid_time:
        doc_ht = DocHybridTime.read(inp)
    return SubDocKey(hash_components, range_components, sub_keys, doc_ht)