docs: public SiteNode addPath(HistoryReference ref, HttpMessage msg, boolean newOnly) {
      	if (Constant.isLowMemoryOptionSet()) {
      		throw new InvalidParameterException("SiteMap should not be accessed when the low memory option is set");
      	}
  
      	if (View.isInitialised() && Constant.isDevMode() && ! EventQueue.isDispatchThread()) {
      		// In developer mode log an error if we're not on the EDT
      		// Adding to the site tree on GUI ('initial') threads causes problems
      		log.error("SiteMap.addPath not on EDT " + Thread.currentThread().getName(), new Exception());
      	}
          
          URI uri = msg.getRequestHeader().getURI();
          log.debug("addPath " + uri.toString());
          
          SiteNode parent = getRoot();
          SiteNode leaf = null;
          String folder = "";
          boolean isNew = false;
          
          try {
              
          	String host = getHostName(uri);
              
              // add host
              parent = findAndAddChild(parent, host, ref, msg);
                       
              List<String> path = model.getSession().getTreePath(msg);
              for (int i=0; i < path.size(); i++) {
              	folder = path.get(i);
                  if (folder != null && !folder.equals("")) {
                      if (newOnly) {
                          // Check to see if it already exists
                          String leafName = getLeafName(folder, msg);
                          isNew = (findChild(parent, leafName) == null);
                      }
                      if (i == path.size()-1) {
                          leaf = findAndAddLeaf(parent, folder, ref, msg);
                          ref.setSiteNode(leaf);
                      } else {
                          parent = findAndAddChild(parent, folder, ref, msg);
                      }
                  }
              }
              if (leaf == null) {
              	// No leaf found, which means the parent was really the leaf
              	// The parent will have been added with a 'blank' href, so replace it with the real one
              	parent.setHistoryReference(ref);
              	leaf = parent;
              }
              
          } catch (Exception e) {
              // ZAP: Added error
              log.error("Exception adding " + uri.toString() + " " + e.getMessage(), e);
          }
          
          if (hrefMap.get(ref.getHistoryId()) == null) {
              hrefMap.put(ref.getHistoryId(), leaf);
          }
  
          if (! newOnly || isNew) {
              return leaf;
          }
          return null;
      }