Fixing empty branch detection to be compatible with Python 3