No, this is not a bug.  Its a quirk in the way Git works, and thus in how TreeWalk works.

Above you converted "folder" from a directory into a file.  These names aren't considered equal by TreeWalk (but they are equal by NameConflictTreeWalk rules).  So you should get "folder" twice in a non-recursive TreeWalk... once as a file, and again as a directory.  Then you get the folder/file path within that (now gone) directory.

If you made the TreeWalk recursive (like the test above) you wouldn't get the folder-as-directory result, and you would only see it appear once.

If you made the TreeWalk be a NameConflictTreeWalk instead, then you would get folder only once.