[patterns] fix recursive pattern expansion