we can follow two approach to solve this problem.

1> If you ae following in/pre/post order then in each node you can check the level of the node and update the sum where level of the node is equal to the given level.

2> Otherwise you can store the node in level order traversal using queue and do a level order traversal to go to a specific level and find the sum of all these nodes.