From d96905437ea043766135ee4c5cd4d32366547288 Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Tue, 23 Apr 2019 22:12:31 +0200 Subject: [PATCH] Add Node.IsLeaf --- node.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/node.go b/node.go index 3b6c1f3..04e6050 100644 --- a/node.go +++ b/node.go @@ -239,6 +239,11 @@ func (n *Node) IsContainer() bool { } } +// IsLeaf returns true if 'n' is a leaf node. +func (n *Node) IsLeaf() bool { + return !n.IsContainer() +} + func (n *Node) canContain(t NodeType) bool { if n.Type == List { return t == Item