A leaf object is an AST object with no child objects connected by outgoing containment relations. During traversal, it contributes one leaf when its settings contain no nested AST objects. section 3.3.2
A recursive counter can inspect each value as an AST object, reference, array, or other value. For an AST object, it counts leaves in the settings; a zero subtotal means the object itself is a leaf. References and unrelated values contribute zero, while arrays sum their elements. section 3.3.2
Counting AST leaves
Implement numberOfLeaves in ast.js, then call numberOfLeaves(astRoot). For the running rental AST, numberOfLeaves(rental) returns 4. The implementation uses isAstObject, isAstReference, Array.isArray, and a reduce-based sum helper. section 3.3.2
