private @NotNull Object getReference(int sessionId, String id) {
    // first lookup in the current session
    Session session = sessions.get(sessionId);
    if (session == null) {
      throw new DriverIlligalStateException("No such session " + sessionId);
    }

    Object value = session.findReference(id);
    if (value != null) return value;

    // otherwise check any sessions
    for (Session s : sessions.values()) {
      value = s.findReference(id);
      if (value != null) return value;
    }

    throw new DriverIlligalStateException("No such reference with id " + id + ". " +
                                          "It may happen if a weak reference to the variable expires. " +
                                          "Please use `Driver.withContext { }` for hard variable references.");
  }
private @NotNull Object getReference(int sessionId, String id)