Invariant measures of nonholonomic flows with internal degrees of freedom