How to avoid code duplication in a function?

The only solution that I've come up with so far then is to make my mode variable and my mode constants global, so I can just make a second function and be done with it. And I should probably just do that instead of wasting time trying to get rid of globals since I already have so many, but using globals everywhere just isn't good coding practice. So I'm looking for a solution which avoids that.

It's important to remember why "using globals everywhere just isn't good coding practice". Essentially, the point is to bring data and the corresponding code together in one place. We're talking about an Arduino sketch so, for the most part, the data and code are already together. In other words, within an Arduino sketch, is there any practical difference between...

static uint8_t mode;

void loop( void )
{
  switch ( mode )
  {
...
  }
}

...and...

void loop( void )
{
  static uint8_t mode;

  switch ( mode )
  {
...
  }
}

Is one going to be easier or harder to debug? If mode is not the expected value, do you have to search through dozens or hundreds of source files where mode is referenced? Is it possible for code outside of the sketch to modify mode in unexpected ways?