Use simple loop to find most frequently used instance.

The original code sort values by copying all key-value pairs
to another TreeMap, which has O(N * logN) complexity and it does
not make the code simpiler either.

A simple loop is faster (it's O(N)) and simpler.
In addition, the original version use `raw types' while it should
use generic types.

So, at any sense, this version is superior.
Refactor sync(context) + getUDID() to getUDID(context).

1. Less error prone, clients need not to initialize first.
2. Enforce thread safety.