// Balance - Re-balance the tree to make it more efficient
Re-balance the tree to make it more efficient
// Balance - Re - balance the tree to make it more efficient
func (tree *LinkedTree) Balance() (*LinkedTreeNode, error) {
	tree.mux.Lock()
	defer tree.mux.Unlock()
	if tree.root != nil {
		node, nodeCount, err := tree.root.Balance(tree.count)
		tree.count = nodeCount
		if err != nil {
			return nil, err
		}
		tree.root = node
		return node, nil
	}
	return nil, fmt.Errorf("Can't balance a tree without a root node")
}
func ( tree * LinkedTree ) Balance ( ) ( * LinkedTreeNode , error ) { tree . mux . Lock ( ) defer tree . mux . Unlock ( ) if tree . root != nil { node , nodeCount , err := tree . root . Balance ( tree . count ) tree . count = nodeCount if err != nil { return nil , err } tree . root = node return node , nil } return nil , fmt . Errorf ( " " ) }
Re-balance the tree to make it more efficient
Re - balance the tree to make it more efficient