model.set("siteType", navigation.getSiteId().getType().getName());
model.set("siteName", navigation.getSiteId().getName());
ModelList nodesModel = model.get("nodes").setEmptyList();
if (rootNode.isChildrenLoaded()) {
for (Node child : rootNode) {
Model childModel = nodesModel.add();
PathAddress childAddress = address.append(child.getName());
if (scope > 0 || scope < 0) // Continue populating nodes in response
{
populateNode(child, scope - 1, childModel.setEmptyObject(), childAddress);
} else { // Populate node reference which can be followed
ModelReference nodeRef = childModel.set(childAddress);
nodeRef.set("name", child.getName());
}
}
}