}, canContain);

  function mapStacks() {
    var containmentStackMap = newBlankObject();
    for (var i = 0, n = elementNames.length; i < n; ++i) {
      var elementName = elementNames[i];
      var stack = containmentStackFor(elementName);
      if (stack && stack.length) { --stack.length; }
      containmentStackMap[elementName] = stack;
    }
    displayJson(containmentStackMap,
                document.getElementById('containment-stack-json'));
  }
  when(mapStacks, containmentStackFor);
}());
</script