Generic binary tree in C# This is a simple implementation of a generic binary tree that holds elements of type T. I was wondering if there was something that could be done better (especially in the EnumerateNodes methods).

using System.Collections.Generic;

namespace DataStructures.Node
{
    /// &lt;summary&gt;
    /// Implements a generic binary tree.
    /// &lt;/summary&gt;
    /// &lt;typeparam name="T"&gt;The type of the nodes&lt;/typeparam&gt;
    public class Node&lt;T&gt;
    {
        #region Private attributes
        private T _node = default(T);
        private Node&lt;T&gt; _leftChild = default(Node&lt;T&gt;);
        private Node&lt;T&gt; _rightChild = default(Node&lt;T&gt;);
        #endregion

        #region Constructor
        public Node()
        {
            _node = default(T);
            _leftChild = null;
            _rightChild = null;
        }

        public Node(T node)
        {
            _node = node;
            _leftChild = null;
            _rightChild = null;
        }
        #endregion

        #region Accessors
        public T Value
        {
            get { return _node; }
            set { _node = value; }
        }

        public Node&lt;T&gt; LeftChild
        {
            get { return _leftChild; }
            set { _leftChild = value; }
        }

        public Node&lt;T&gt; RightChild
        {
            get { return _rightChild; }
            set { _rightChild = value; }
        }

        /// &lt;summary&gt;
        /// Returns the total number of elements in the tree.
        /// &lt;/summary&gt;
        public int Count
        {
            get { return count(); }
        }
        #endregion

        #region Private methods

        private int count()
        {
            if (_leftChild == null &amp;&amp; _rightChild == null)
                return 1;
            if (_leftChild == null)
                return 1 + _rightChild.count();
            if (_rightChild == null)
                return 1 + _leftChild.count();
            else
                return 1 + _leftChild.count() + _rightChild.count();
        }

        #endregion

        #region Public methods

        /// &lt;summary&gt;
        /// Adds the element on the right branch of the node.
        /// &lt;/summary&gt;
        /// &lt;param name="rightBranch"&gt;Node to add on the right side of the node.&lt;/param&gt;
        public void AddRight(Node&lt;T&gt; rightBranch)
        {
            _rightChild = rightBranch;
        }

        /// &lt;summary&gt;
        /// Adds the element on the left branch of the node.
        /// &lt;/summary&gt;
        /// &lt;param name="leftBranch"&gt;Node to add on the left side of the node.&lt;/param&gt;
        public void AddLeft(Node&lt;T&gt; leftBranch)
        {
            _leftChild = leftBranch;
        }

        public IEnumerable&lt;T&gt; EnumerateNodes()
        {
            yield return _node;
            if (_leftChild != null)
                foreach (T child in _leftChild.EnumerateNodes())
                    yield return child;
            if (_rightChild != null)
                foreach (T child in _rightChild.EnumerateNodes())
                    yield return child;
        }

        #endregion
    }
}
Here's an alternative way to write count().  It's shorter and uses expressions instead of statements.  You can't do as much in an expression, so I use them instead of statements when possible because there's a lower chance of things going wrong.  Readability is more important than those things, though, so I recommend using what is most readable to you.

private int count()
{
    return 1 +
        (_leftChild != null ? _leftChild.count() : 0) +
        (_rightChild != null ? _rightChild.count() : 0);
}


Or if you want to use C# 6 null checking:

private int count()
{
    return 1 + (_leftChild?.count() ?? 0) + (_rightChild?.count() ?? 0);
}


Method names should be UpperCamelCase, so count() should be Count().  I'm guessing you want to access a child's Count property instead of the method because the method is private.