OAK-1768: DocumentNodeBuilder.setChildNode() runs OOM with large tree

Merge revisions 1623827,1624993,1627470 from trunk

git-svn-id: https://svn.apache.org/repos/asf/jackrabbit/oak/branches/1.0@1627494 13f79535-47bb-0310-9956-ffa450edef68