def get_field_or_message(message, field_str):
    """Get the field value or entire message if it is already a leaf."""
    data = message
    if field_str is not None:
        fields = field_str.split('/')
        while len(fields) > 0:
            field = fields.pop(0)
            data = getattr(data, field)
    return data