code: public static boolean isLeaf(Node node) {
          return node instanceof Leaf || node.children() == null || node.children().size() == 0;
      }
docs: Returns true if a node is a leaf. Note that a leaf can also be a parent node that does not have any children.