Yes, your right the bar is there mainly for tree protection.
When London Transport was in existence all tree's were lopped/pruned so as not to extend past the kerb line. They actually had a double deck bus to use as a template gauge. It had no glass in the windows any offending branches could be lopped off in situ.
Nowadays it's TFL's responsibility and all they do is notify the local councils of overhanging branches and they are supposed to trim them which they rarely do.
Much cheaper to have a bar there than replace expensive window glass.