public final static Comparator<NodeModel> comparator() {
		return new Comparator<NodeModel>() {
			private final HashMap<NodeModel, NodeAbsolutePath> paths = new HashMap<>(); 

			@Override
			public int compare(NodeModel o1, NodeModel o2) {
				if(o1 == o2)
					return 0;
				if(o1 == null)
					return -1;
				if(o2 == null)
					return 1;
				final NodeAbsolutePath absoluteBeginPath = getPath(o1);
				final NodeAbsolutePath absoluteEndPath = getPath(o2);
				return new NodeRelativePath(absoluteBeginPath, absoluteEndPath).compareNodePositions();
			}

			public NodeAbsolutePath getPath(NodeModel node) {
				NodeAbsolutePath path = paths.get(node);
				if(path == null) {
					path = new NodeAbsolutePath(node);
					paths.put(node, path);
				}
				else
					path.reset();
				return path;
			}
		};
	}
@Test
	public void compareNodesWithSameParentUsingComparator(){
		final NodeModel parent = root();
		final NodeModel node1 = new NodeModel("node1", map);
		parent.insert(node1);
		final NodeModel node2 = new NodeModel("node2", map);
		parent.insert(node2);
		final int compared = NodeRelativePath.comparator().compare(node2, node1);
		assertTrue(compared > 0);
	}