Stop a branch if list is empty

Please try to search for similar topics before posting a new one. This question has been asked many times before.