A possible solution could be the following: Create a new formula, rename it to IsFolder and paste the following text into the formula editor:
$strFolder : ".FLD"$.Name
Then you could call this helper formula like this:
If IsFolder("Folder") Then ...
If IsFolder("AFolderAnotherFolder") Then ...
The formula IsFolder tries to convert the object name into a reference to the object. If the object exists this is possible and accessing the Name property of the folder is a valid operation. Otherwise an error will occur which will be catched by the catch statement. The variable Err contains the error message as a string, but we do not need it here.