diff --git a/trie/hasher.go b/trie/hasher.go
index 2fc44787ac993bccd1fabfa65433ae8b212f9dd2..ff61e7092240fdfb7acb77f5e53deae3ba49d1a4 100644
--- a/trie/hasher.go
+++ b/trie/hasher.go
@@ -196,12 +196,12 @@ func (h *hasher) store(n node, db *Database, force bool) (node, error) {
 		if h.onleaf != nil {
 			switch n := n.(type) {
 			case *shortNode:
-				if child, ok := n.Val.(valueNode); ok {
+				if child, ok := n.Val.(valueNode); ok && child != nil {
 					h.onleaf(child, hash)
 				}
 			case *fullNode:
 				for i := 0; i < 16; i++ {
-					if child, ok := n.Children[i].(valueNode); ok {
+					if child, ok := n.Children[i].(valueNode); ok && child != nil {
 						h.onleaf(child, hash)
 					}
 				}