correctly handles leafnodes