diff --git a/basicnode.go b/basicnode.go index 6cf5671..5404013 100644 --- a/basicnode.go +++ b/basicnode.go @@ -24,6 +24,9 @@ func (n *basicNode) Parent() Node { // Child returns current node child at specified quadrant. func (n *basicNode) Child(q Quadrant) Node { + if n.c[q] == nil { + return nil + } return n.c[q] } diff --git a/cnnode.go b/cnnode.go index 9f5a22b..53d1381 100644 --- a/cnnode.go +++ b/cnnode.go @@ -50,6 +50,9 @@ func (n *cnNode) Parent() Node { // Child returns current node child at specified quadrant. func (n *cnNode) Child(q Quadrant) Node { + if n.c[q] == nil { + return nil + } return n.c[q] }