The current branch lookup code is ugly (and inefficient but OK). It could be made a lot better with schema changes (lowercased version of all branch names for lookup) or the new collation feature in MongoDB http://plusnconsulting.com/post/MongoDB-Dont-be-so-case-sensitive/
As is, it is also currently bug-prone because it is spaghetti-like.
The current branch lookup code is ugly (and inefficient but OK). It could be made a lot better with schema changes (lowercased version of all branch names for lookup) or the new collation feature in MongoDB http://plusnconsulting.com/post/MongoDB-Dont-be-so-case-sensitive/
As is, it is also currently bug-prone because it is spaghetti-like.