added recursive function to handle active for nested select options