BUGFIX: branch2idx and merge2idx should handle middle switches