Reorganize nodes and links data objects with Javascript prototype