Implement an algorithm to parse and validate complex configuration files such as JSON or YAML used in developer workplace integrations at Versant Media.
Implement parse_and_validate(text, required_keys). Parse JSON input without relying on a JSON parsing library. Return the parsed Python value when the document is valid, is a top-level object, contains every required key, and has no duplicate keys. Return None for malformed JSON, trailing content, duplicate keys, excessive nesting, or missing required keys. Support objects, arrays, strings with standard JSON escapes, numbers, booleans, and null.
The input is a string and a list of required string keys. Limit nesting depth to 100.
def parse_and_validate(text, required_keys):