Fix deletion of symlink to directory

`is_dir` returns true on a symbolic link to a directory. Because of the
order of these conditionals, a `rmdir` would be incorrectly called on a
symlink to a directory.