static variable with recursion

Hi , Inside a recursive function i have a static variable, when i return that static variable , it's value becomes zero.
count = trimWS(someXMLNode);
i get count as 0 , but when i debug countWS was 9.
Pls help me why this is happening and what is the right way to return some value from recursive function.