Added a firstNeighbor field to DetectStructureResults and used it instead of writing more complicated logic