Refactoring: extract method for similar code

git-svn-id: https://svn.sosy-lab.org/software/cpachecker/trunk@13578 4712c6d2-40bb-43ae-aa4b-fec3f1bdfe4c