private static void AddLonelyNodes(LeetCode1469Node root)
            {
                if (root == null)
                {
                    return;
                }

                if (HasRightChild(root))
                {
                    results.Add(root.right.val);
                }

                if (HasLeftChild(root))
                {
                    results.Add(root.left.val);
                }

                AddLonelyNodes(root.left);
                AddLonelyNodes(root.right);
            }
 public LeetCode1469Node(int val = 0, LeetCode1469Node left = null, LeetCode1469Node right = null)
 {
     this.val   = val;
     this.left  = left;
     this.right = right;
 }
 private static bool HasLeftChild(LeetCode1469Node root)
 {
     return(root.left != null && root.right == null);
 }
 public static IList <int> GetLonelyNodes(LeetCode1469Node root)
 {
     AddLonelyNodes(root);
     return(results);
 }