code: public static synchronized OmemoManager getInstanceFor(XMPPConnection connection) {
          TreeMap<Integer, OmemoManager> managers = INSTANCES.get(connection);
          if (managers == null) {
              managers = new TreeMap<>();
              INSTANCES.put(connection, managers);
          }
  
          OmemoManager manager;
          if (managers.size() == 0) {
  
              manager = new OmemoManager(connection, UNKNOWN_DEVICE_ID);
              managers.put(UNKNOWN_DEVICE_ID, manager);
  
          } else {
              manager = managers.get(managers.firstKey());
          }
  
          return manager;
      }
docs: Returns an OmemoManager instance for the given connection. If there was one manager for the connection before,
  return it. If there were multiple managers before, return the one with the lowest deviceId.
  If there was no manager before, return a new one. As soon as the connection gets authenticated, the manager
  will look for local deviceIDs and select the lowest one as its id. If there are not local deviceIds, the manager
  will assign itself a random id.
  
  @param connection XmppConnection.
  
  @return manager