add license
abstract shared code between arrays and objects for getting replacement node