function getLastChild(aNode) { if (!PlacesUtils.nodeIsFolder(aNode) && !PlacesUtils.nodeIsQuery(aNode)) return aNode; aNode = aNode.QueryInterface(Ci.nsINavHistoryContainerResultNode); aNode.containerOpen = true; return arguments.callee(aNode.getChild(aNode.childCount-1)); } var result = HistoryService.executeQuery(query, options); getLastChild(result.root);