The array in line 186 is indexed by the child name i.e. the last part of the subject or id. The array $expectedOrder has the complete subjects, so we have to strip the parents path to get just the node name so we can compare apples with apples. This is PHPCR specific.