One way to codify the large number of variables that control the mechanistic pathways for substitution and elimination reactions is to use a decision tree.
Write the structure of your reactant, the solvent, and the nucleophile. Check the substitution level of the carbon to which your leaving group is attached.
Then start in the upper left of the chart. Ask the first question and follow the branches according to whether your answer is yes or no.