Build binary tree from level order array

I am new to elixer, I need some help to construct binary tree from list of element(given in level order). Due to immutability i’m facing difficutly to implement this.
For ex: [1, 2, 3, -1, -1, -1, -1] will be represented as:

                  1
                /   \
              2       3

Here -1 means, node will be null.

Expected Output Format:

TreeNode{
	data: 1,
	left: TreeNode{
		data: 2,
		left: nil,
		right: nil
	},
	right: TreeNode{
		data: 3,
		left: nil,
		right: nil
	}	
}

In ruby, we can implement in this way.

def input_tree(input)
	val = input[0]
	input.shift()
	root = TreeNode.new(val)
	queue = []
	queue.push(root)
	
	while queue.size > 0
		current_node = queue[0]
		queue.shift()
		
		leftValue = input[0]
		input.shift()
	
		rightValue = input[0]
		input.shift()
		
		if leftValue != -1
			leftNode = TreeNode.new(leftValue)
			current_node.left = leftNode
			queue.push(leftNode)
		end
		
		if rightValue != -1
			rightNode = TreeNode.new(rightValue)
			current_node.right = rightNode
			queue.push(rightNode)
		end
	end
	return root
end

TIA :slight_smile: