func (t *tree) Last() (interface{}, bool) {
	if t.len == 0 {
		return nil, false
	}
	n := t.getLastNode()
	return n.value, true
}
Last returns the last value of the tree and true, or false if there is no value
package binarysearchtree
import (
	List "github.com/zimmski/container/list"
	dll "github.com/zimmski/container/list/doublylinkedlist"
	Tree "github.com/zimmski/container/tree"
)
type node struct {
	parent *node        
	left   *node        
	right  *node        
	value  interface{}  
}
type iterator struct {
	tree    *tree      
	current *node      
	stack   List.List  
}
func (iter *iterator) Next() Tree.Iterator {
	if iter.current != nil {
		if iter.current.right != nil {
			iter.current = iter.current.right
			iter.stack.Push(iter.current)
			for iter.current.left != nil {
				iter.current = iter.current.left
				iter.stack.Push(iter.current)
			}
		}
		if iter.stack.Len() == 0 {
			iter.current = nil
		} else {
			c, _ := iter.stack.Pop()
			iter.current = c.(*node)
		}
	}
	if iter.current == nil {
		return nil
	}
	return iter
}
func (iter *iterator) Previous() Tree.Iterator {
	if iter.current != nil {
		if iter.current.left != nil {
			iter.stack.Push(iter.current)
			iter.current = iter.current.left
			for iter.current.right != nil {
				iter.stack.Push(iter.current)
				iter.current = iter.current.right
			}
		} else {
			if iter.stack.Len() != 0 {
				if c, _ := iter.stack.First(); c.(*node).parent == nil {
					var last, p *node
					it := iter.stack.Iter()
					for ; it != nil; it = it.Next() {
						last = it.Get().(*node)
						if last.parent != p || (p != nil && p.left != last) {
							break
						}
						p = last
					}
					if it == nil && last.left == iter.current {
						iter.stack.Clear()
						iter.current = nil
						return nil
					}
				}
				if iter.tree.compare(iter.current.parent.value, iter.current.value) < 0 {
					iter.current = iter.current.parent
					if last, _ := iter.stack.Last(); iter.tree.compare(last.(*node).value, iter.current.value) == 0 {
						iter.stack.Pop()
					}
				} else {
					c, _ := iter.stack.Pop()
					if iter.stack.Len() != 0 {
						if iter.tree.compare(c.(*node).value, iter.current.value) > 0 {
							for iter.tree.compare(c.(*node).parent.value, iter.current.value) > 0 {
								c, _ = iter.stack.Pop()
							}
							iter.stack.Pop()
						}
					}
					iter.current = c.(*node).parent
				}
			} else {
				iter.current = iter.current.parent
			}
		}
	}
	if iter.current == nil {
		return nil
	}
	return iter
}
func (iter *iterator) Get() interface{} {
	return iter.current.value
}
type tree struct {
	root    *node                       
	len     int                         
	compare func(a, b interface{}) int  
}
func New(compare func(a, b interface{}) int) *tree {
	t := new(tree)
	t.compare = compare
	t.Clear()
	return t
}
func (t *tree) Clear() {
	if t.len != 0 {
		stack := dll.New()
		stack.Push(t.root)
		for stack.Len() != 0 {
			cr, _ := stack.Pop()
			c := cr.(*node)
			c.parent = nil
			if c.right != nil {
				stack.Push(c.right)
				c.right = nil
			}
			if c.left != nil {
				stack.Push(c.left)
				c.left = nil
			}
		}
	}
	t.root = nil
	t.len = 0
}
func (t *tree) Len() int {
	return t.len
}
func (t *tree) Empty() bool {
	return t.len == 0
}
func (t *tree) newNode(v interface{}) *node {
	return &node{
		value: v,
	}
}
func (t *tree) getNode(id interface{}) *node {
	if t.len == 0 {
		return nil
	}
	c := t.root
	for {
		r := t.compare(id, c.value)
		if r == 0 {
			break
		} else if r < 0 {
			if c.left != nil {
				c = c.left
			} else {
				return nil
			}
		} else {
			if c.right != nil {
				c = c.right
			} else {
				return nil
			}
		}
	}
	return c
}
func (t *tree) getNodeFunc(m func(v interface{}) bool) *node {
	stack := dll.New()
	stack.Push(t.root)
	for stack.Len() != 0 {
		cr, _ := stack.Pop()
		c := cr.(*node)
		if m(c.value) {
			return c
		}
		if c.right != nil {
			stack.Push(c.right)
		}
		if c.left != nil {
			stack.Push(c.left)
		}
	}
	return nil
}
func (t *tree) getFirstNode() *node {
	if t.len == 0 {
		return nil
	}
	c := t.root
	for c.left != nil {
		c = c.left
	}
	return c
}
func (t *tree) getLastNode() *node {
	if t.len == 0 {
		return nil
	}
	c := t.root
	for c.right != nil {
		c = c.right
	}
	return c
}
func (t *tree) insert(v interface{}) *node {
	n := t.newNode(v)
	if t.len == 0 {
		t.root = n
	} else {
		c := t.root
		for {
			if t.compare(n.value, c.value) <= 0 {
				if c.left != nil {
					c = c.left
				} else {
					c.left = n
					n.parent = c
					break
				}
			} else {
				if c.right != nil {
					c = c.right
				} else {
					c.right = n
					n.parent = c
					break
				}
			}
		}
	}
	t.len++
	return nil
}
func (t *tree) removeNode(c *node) interface{} {
	if c == nil {
		return nil
	}
	if c.left == nil && c.right == nil {
		if c.parent != nil {
			if c.parent.left == c {
				c.parent.left = nil
			} else {
				c.parent.right = nil
			}
		}
		if t.root == c {
			t.root = nil
		}
	} else if c.left != nil {
		c.left.parent = c.parent
		if c.parent != nil {
			if c.parent.left == c {
				c.parent.left = c.left
			} else {
				c.parent.right = c.left
			}
		}
		if c.right != nil {
			r := c.left
			for {
				if r.right == nil {
					r.right = c.right
					c.right.parent = r
					break
				}
				r = r.right
			}
		}
		if t.root == c {
			t.root = c.left
		}
	} else {
		c.right.parent = c.parent
		if c.parent != nil {
			if c.parent.left == c {
				c.parent.left = c.right
			} else {
				c.parent.right = c.right
			}
		}
		if t.root == c {
			t.root = c.right
		}
	}
	c.parent = nil
	c.left = nil
	c.right = nil
	t.len--
	return c.value
}
func (t *tree) Chan(n int) <-chan interface{} {
	ch := make(chan interface{})
	go func() {
		for iter := t.Iter(); iter != nil; iter = iter.Next() {
			ch <- iter.Get()
		}
		close(ch)
	}()
	return ch
}
func (t *tree) ChanBack(n int) <-chan interface{} {
	ch := make(chan interface{})
	go func() {
		for iter := t.IterBack(); iter != nil; iter = iter.Previous() {
			ch <- iter.Get()
		}
		close(ch)
	}()
	return ch
}
func (t *tree) Iter() Tree.Iterator {
	if t.len == 0 {
		return nil
	}
	iter := &iterator{
		tree:    t,
		current: t.root,
		stack:   dll.New(),
	}
	iter.stack.Push(iter.current)
	for iter.current.left != nil {
		iter.current = iter.current.left
		iter.stack.Push(iter.current)
	}
	c, _ := iter.stack.Pop()
	iter.current = c.(*node)
	return iter
}
func (t *tree) IterBack() Tree.Iterator {
	if t.len == 0 {
		return nil
	}
	iter := &iterator{
		tree:    t,
		current: t.getLastNode(),
		stack:   dll.New(),
	}
	return iter
}
func (t *tree) First() (interface{}, bool) {
	if t.len == 0 {
		return nil, false
	}
	n := t.getFirstNode()
	return n.value, true
}