GVariant: add internal tree-form locking helper