I have a doubt regarding this algorithm if we encounter the value of m.count(hd)==1 means there is already a value inside the map which having the same hd . i want to confirm that in that case we are not pushing the value having same hd into the map?

while (q.size()) {
hd = root->hd;

    // count function returns 1 if the container
    // contains an element whose key is equivalent
    // to hd, or returns zero otherwise.
    if (m.count(hd) == 0)
        m[hd] = root->data;
    if (root->left) {
        root->left->hd = hd - 1;
        q.push(root->left);
    }
    if (root->right) {
        root->right->hd = hd + 1;
        q.push(root->right);
    }
    q.pop();
    root = q.front();
}