detect optional keys in arrays
refactored
draft4 working, but not sure about desired behavior for a few complex scenarios.
fix detect_optional that was broken by draft4