LeetCode: Binary Tree Level Order Traversal C# Please review for performance. and also naming convention

https://leetcode.com/problems/binary-tree-level-order-traversal/


  Given a binary tree, return the level order traversal of its nodes'
  values. (ie, from left to right, level by level).
  
  For example:

Given binary tree [3,9,20,null,null,15,7],
    3
   / \
  9  20
    /  \
   15   7

return its level order traversal as:
[
  [3],
  [9,20],
  [15,7]
]



using System.Collections.Generic;
using System.Linq;
using GraphsQuestions;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace TreeQuestions
{
    /// &lt;summary&gt;
    /// https://leetcode.com/problems/binary-tree-level-order-traversal/
    /// &lt;/summary&gt;
    [TestClass]
    public class BinaryTreeLevelOrderTraversalTest
    {

        //      3
        //     / \
        //    9  20
        //   /  \
        //  15   7
        [TestMethod]
        public void TreeTest()
        {
            TreeNode root = new TreeNode(3);
            root.left = new TreeNode(9);
            root.right = new TreeNode(20);
            root.left.left = new TreeNode(15);
            root.left.right = new TreeNode(7);
            IList&lt;IList&lt;int&gt;&gt; res = BinaryTreeLevelOrderTraversalClass.LevelOrder(root);
            CollectionAssert.AreEqual(res[0].ToList(), new List&lt;int&gt;{3});
            CollectionAssert.AreEqual(res[1].ToList(), new List&lt;int&gt;{9,20});
            CollectionAssert.AreEqual(res[2].ToList(), new List&lt;int&gt;{15,7});
        }


        [TestMethod]
        public void OneNodeTreeTest()
        {
            TreeNode root = new TreeNode(3);
            IList&lt;IList&lt;int&gt;&gt; res = BinaryTreeLevelOrderTraversalClass.LevelOrder(root);
            CollectionAssert.AreEqual(res[0].ToList(), new List&lt;int&gt; { 3 });
        }
    }

    public class BinaryTreeLevelOrderTraversalClass
    {
        public static IList&lt;IList&lt;int&gt;&gt; LevelOrder(TreeNode root)
        {
            List&lt;IList&lt;int&gt;&gt; res = new List&lt;IList&lt;int&gt;&gt;();
            if (root == null)
            {
                return res;
            }
            Queue&lt;TreeNode&gt; Q = new Queue&lt;TreeNode&gt;();

            Q.Enqueue(root);

            int counter = 0; // which level
            while (Q.Count &gt; 0)
            {
                int children = Q.Count;
                res.Add(new List&lt;int&gt;());
                for (int i = 0; i &lt; children; i++)
                {
                    var temp = Q.Dequeue();
                    res[counter].Add(temp.val);
                    if (temp.left != null)
                    {
                        Q.Enqueue(temp.left);
                    }
                    if (temp.right != null)
                    {
                        Q.Enqueue(temp.right);
                    }
                }
                counter++;
            }
            return res;
        }
    }

}
Avoid unnecessary variables

The counter variable is unnecessary.
For each level, you need just a List&lt;int&gt; level,
add the elements of the level to this list,
and then add this list to res.

By eliminating this variable, you also eliminate any concerns about the correctness of res[counter].Add(temp.val);.
With the code changed to level.Add(temp.val),
the mental burden is reduced.

Use more descriptive names


res could be levels
temp could be node
LevelOrder could be GetLevels
BinaryTreeLevelOrderTraversalClass would be better without Class