I had a very similar problem. I found a solution for this, here is the code:
...
VersionControlServer vcs = tfs.GetService(typeof(VersionControlServer));
BranchObject[] allBranches = vcs.QueryRootBranchObjects(RecursionType.Full);
string myItem = "$/My Project/some Path including the branch/myFile.txt";
foreach(BranchObject branch in allBranches)
{
if(myItem.Contains(branch.Properties.RootItem.Item))
{
}
}
...
I hope this helps someone with this problem, I think op has already solved this (some time has passed since he asked the question).
source
share