add get all groups

Probably worth adding a comment explaining that encoding and decoding are the same operation, otherwise it looks strange to see "encode" where one expects "decode".