add recursion support for optional