To de-duplicate these entries, you should use the namespace ID for each shared/team folder. I.e., the "shared folder ID" or "team folder ID". These IDs will be consistent across user accounts, even if the path of the folder is not.
You can determine if a user is on a team that uses the "team space" by checking the FullAccount.root_info returned by users_get_current_account. You can check if the type of the RootInfo is a TeamRootInfo or a UserRootInfo. Check out those links for more information on that.
I also recommend reviewing the Namespace Guide and Content Access Guide for more information, if you haven't already.