You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: 1022. Sum of Root To Leaf Binary Numbers.go
    path of file: ./repos/LeetCode-Go/leetcode/1022.Sum-of-Root-To-Leaf-Binary-Numbers
    
    the code of the file until where you have to start completion: package leetcode

import "github.com/halfrost/LeetCode-Go/structures"

// T
    
func sumRootToLeaf(root *TreeNode) int {
	var dfs func(*TreeNode, int) int
	dfs = func(node *TreeNode, sum int) int {
		if node == nil {
			return 0
		}
		sum = sum<<1 | node.Val
		// 上一行也可以写作 sum = sum*2 + node.Val
		if node.Left == nil && node.Right == nil {
			return sum
		}
		return dfs(node.Left, sum) + dfs(node.Right, sum)
	}
	return dfs(root, 0)
}