1
var createBinaryTree = function (descriptions) {4
for (let [parent, child, isLeft] of descriptions) {5
let parentNode = nodes.get(parent) || new TreeNode(parent);6
if (!nodes.has(parent)) nodes.set(parent, parentNode);8
let childNode = nodes.get(child) || new TreeNode(child);9
if (!nodes.has(child)) nodes.set(child, childNode);11
if (isLeft) parentNode.left = childNode;12
else parentNode.right = childNode;17
for (let [parent, child, isLeft] of descriptions) {18
// a node with no parent is the root19
if (!children.has(parent)) return nodes.get(parent);