Added enumeration support for optional tree's

First improvement for issue #625