This method is trying to do too many things, which makes it confusing (and hard to test). I think you should extract several methods from this: `is_folder`, `is_hidden_file`, and `get_file`. Then, the calling method should do the tests (`is_folder` and `is_hidden_file`) first, and only call `get_file`  method if it actually wants to get the file.