Base code
Construct complete YAML document. Call the second step in case of recursive structures. At the end cleans all the state.
Ensure that the stream contains a single document and construct it