code: private MobicentsSipSession retrieveSipSession(Dialog dialog) {
  		
  		if(dialog != null) {
  			Iterator<SipContext> iterator = sipApplicationDispatcher.findSipApplications();
  			while(iterator.hasNext()) {
  				SipContext sipContext = iterator.next();
  				SipManager sipManager = sipContext.getSipManager();
  				
  				Iterator<MobicentsSipSession> sipSessionsIt= sipManager.getAllSipSessions();
  				while (sipSessionsIt.hasNext()) {
  					MobicentsSipSession mobicentsSipSession = (MobicentsSipSession) sipSessionsIt
  							.next();
  					MobicentsSipSessionKey sessionKey = mobicentsSipSession.getKey();				
  					if(sessionKey.getCallId().trim().equals(dialog.getCallId().getCallId())) {
  						if(logger.isDebugEnabled()) {
  							logger.debug("found session with the same Call Id " + sessionKey + ", to Tag " + sessionKey.getToTag());
  							logger.debug("dialog localParty = " + dialog.getLocalParty().getURI() + ", localTag " + dialog.getLocalTag());
  							logger.debug("dialog remoteParty = " + dialog.getRemoteParty().getURI() + ", remoteTag " + dialog.getRemoteTag());
  						}
  						if(sessionKey.getFromTag().equals(dialog.getLocalTag()) && sessionKey.getToTag().equals(dialog.getRemoteTag())) {
  							if(mobicentsSipSession.getProxy() == null) {
  								return mobicentsSipSession;	
  							}
  						} else if (sessionKey.getFromTag().equals(dialog.getRemoteTag()) && sessionKey.getToTag().equals(dialog.getLocalTag())){
  							if(mobicentsSipSession.getProxy() == null) {
  								return mobicentsSipSession;	
  							}
  						}
  					}
  				}
  			}
  		}
  		
  		return null;
  	}
docs: Try to find a matching Sip Session to a given dialog
  @param dialog the dialog to find the session
  @return the matching session, null if not session have been found