Split walkLemma into smaller functions.