public bool IsBalanced() { int LeftHeight = LeftNode != null?LeftNode.Height() : 0; int RightHeight = RightNode != null?RightNode.Height() : 0; int heightDifference = LeftHeight - RightHeight; if (Math.Abs(heightDifference) > 1) { return(false); } else { return((LeftNode != null ? LeftNode.IsBalanced() : true) && (RightNode != null ? RightNode.IsBalanced() : true)); } }