function key2gID = uniqueKeyToGroupID(groups)
    % UNIQUEKEYTOGROUPID function
    % This function returns a containers.Map object that maps from a unique
    % key of a group member to a group ID 
    
    % Copyright 2019 The MathWorks, Inc.
    
    key2gID = containers.Map();
    for gIndex = 1:numel(groups)
        % get all the members
        members = groups{gIndex}.getGroupMembers;
        for mIndex = 1:numel(members)
            % get the unique key of the member
            uniqueKey = members{mIndex}.getUniqueIdentifier.UniqueKey;
            % register it to the group ID
            key2gID(uniqueKey) = groups{gIndex}.id;
        end
    end
end