How to find the conditional branch instruction?

I have a cpp source code line and I can easily get its corresponding human readable LLVM bitcode line from LLVM bitcode. I want to find the nearest conditional branch that will allow this line to execute. It is possible that the line itself can be the branch. If not, the branch can be the nearest branch before this line. Please tell me how I can get this branch instruction.

The solution will probably first create a graph. Then the bitcode line should help the solution to find the line in the graph. Then the solution will check if it is a branch or decrement an iterator one instruction at a time and check if the earlier instruction is a branch.

I hope the above steps are correct and possible to be done. I am asking the actual details or instructions or methods that I can use to implement this.