added is_leaf helper func