func (n *node) Remove() bool {
	if !n.IsDir() {
		if n.HasWatcher() {
			n.Value = ""
			n.AsDir()
			return true
		}
		if n.parent != nil && n.parent.Children[n.Name] == n {
			delete(n.parent.Children, n.Name)
			n.Notify(Delete)
			n.parent.Clean()
			return true
		}
		return false
	}
	n.Value = ""
	for _, node := range n.Children {
		node.Remove()
	}
	if n.parent != nil && n.parent.Children[n.Name] == n && n.ChildrenCount() == 0 && !n.HasWatcher() {
		delete(n.parent.Children, n.Name)
		n.parent.Clean()
		return true
	}
	return false
}
Remove function remove the node.
package store
import (
	"container/list"
	"encoding/json"
	"errors"
	"path"
	"sync"
)
type node struct {
	Name string `json:"name"`
	parent *node
	watchers *list.List
	Value    string           `json:"value"`     
	Children map[string]*node `json:"children"`  
	store *store  
	watcherLock sync.RWMutex
}
func newKV(store *store, nodeName string, value string, parent *node) *node {
	if len(nodeName) == 0 {
		panic(errors.New("nodeName can not be emtpy."))
	}
	n := &node{
		Name:        nodeName,
		parent:      parent,
		watchers:    nil,
		Children:    nil,
		Value:       value,
		store:       store,
		watcherLock: sync.RWMutex{},
	}
	parent.Add(n)
	n.Notify(Update)
	return n
}
func newDir(store *store, nodeName string, parent *node) *node {
	if len(nodeName) == 0 {
		panic(errors.New("nodeName can not be emtpy."))
	}
	n := &node{
		Name:     nodeName,
		parent:   parent,
		watchers: nil,
		Children: make(map[string]*node),
		store:    store,
	}
	if parent != nil {
		parent.Add(n)
	}
	return n
}
func (n *node) Path() string {
	if n.parent == nil {
		return n.Name
	} else {
		return path.Join(n.parent.Path(), n.Name)
	}
}
func (n *node) RelativePath(end *node) string {
	if n.parent == nil || n == end {
		return "/"
	} else {
		return path.Join(n.parent.RelativePath(end), n.Name)
	}
}
func (n *node) IsRoot() bool {
	return n.parent == nil
}
func (n *node) IsDir() bool {
	return n.Children != nil
}
func (n *node) AsDir() {
	if !n.IsDir() {
		n.Children = make(map[string]*node)
	}
	n.Notify(Delete)
}
func (n *node) AsLeaf() {
	if n.IsDir() {
		n.Children = nil
	}
	n.Notify(Update)
}
func (n *node) Read() string {
	return n.Value
}
func (n *node) Write(value string) {
	if n.IsRoot() {
		return
	}
	oldValue := n.Value
	n.Value = value
	if n.IsDir() {
		if n.ChildrenCount() == 0 {
			n.AsLeaf()
		}
	} else {
		if oldValue != value {
			n.Notify(Update)
		}
	}
}
func (n *node) List() []*node {
	if !n.IsDir() {
		return make([]*node, 0)
	}
	nodes := make([]*node, len(n.Children))
	i := 0
	for _, node := range n.Children {
		nodes[i] = node
		i++
	}
	return nodes
}
func (n *node) GetChild(name string) *node {
	if !n.IsDir() {
		return nil
	}
	child, ok := n.Children[name]
	if ok {
		return child
	}
	return nil
}
func (n *node) ChildrenCount() int {
	if n.IsDir() {
		return len(n.Children)
	}
	return 0
}
func (n *node) Add(child *node) {
	if !n.IsDir() {
		n.AsDir()
	}
	n.Children[child.Name] = child
}