const traverseInOrder = (root) => {
  const result = []

  function traverseInOrderHelper(node) {
    if (!node) return

    traverseInOrderHelper(node.left)

    result.push(node.val)

    traverseInOrderHelper(node.right)
  }

  traverseInOrderHelper(root)

  return result
}

module.exports = traverseInOrder
