getCannonicalIdFromElem() helper