Change add_leaf function to require_node and specify its behavior