Also, shouldn't the logic be opposite?
As in if it has ```[]``` it should be skipped(continue), and if it does not it should check if there is one with and merge it in, or?