If the low 5 bits are 0x1F, then the identifier is encoded in multiple octets. The 0x1F is not a part of the identifier value. If the low 5 bits are < 0x1F, then that is your identifier (<=30). All you have to do is examine the low 5 bits of the first octet and compare to 0x1F.