python nested function code complexity