I think this would be better specified to return a `Set<Integer>`, since it has no ordering to communicate and it is at least implicitly specified as returning a container containing no duplicates.  The `contains` conditional could be eliminated, for instance, because the algorithm becomes add all the encountered non-zero layout IDs to the set, and the Set will itself implement ignoring adds of duplicates.