I think that the best approach is to use lazy load functionality. Fist of all, you can use solution from link that you provided to build fist level of the webs structure. In the onWebsLoaded method you can create html element that expands next menu items level. On this element you can set onclick event handler that retrieves server relative url of the web that is associated with this element, retrive the web by this url and load sub webs as describet in the post. Then create a new level of menu. You can repeat this steps for the next level of items.
You can store server relative url of the web in the attribute of html element. In the onclick event of this element you can retrieve this url and use this code
var url = $(this).attr("serverRelativeUrl");
var clientContext = new SP.ClientContext(url);
this.subwebs = clientContext.get_web().get_webs();
clientContext.load(this.subwebs);
clientContext.executeQueryAsync(onRequestSucceeded, onRequestFailed);
then you can create and add new links based on response.