Compare DOM tree order of elements