#Java 10, <s>145</s> <s>129</s> <s>107</s> <s>106</s> <s>103</s> <s>93</s> 77 bytes <!-- language-all: lang-java --> Loads of bytes saved thanks to *@Frozn*, and by using `Object` as return-type, we can comply with OP's rules of returning the input-array when the array is empty, despite Java's one-return-type-only nature regarding methods. m->{int f=1;for(var a:m)f=m[0].length!=a.length?0:f;return m.length<1?m:f>0;} [Try it online.](https://tio.run/##rU9Pa4MwFL/7Kd5uClaM7cnM9hOsPfQoHtI06XQmlhgtQ/LZ3XOVbofBEAohvOT3fv8q1rNVdf4Yec3aFt5YqQcPoNRWGMm4gP30BDicKsEtcB@RvMgLUAFFwHl4tZbZksMeNGQwqtV2wCWQGaGyMX7PDLBUBTJTeVxEtdAX@/6SsXnaxamkRtjOaFDz3yvZqVRuY@pGOhlcu1ONBrNP35RnUBjUP1pT6guGYcE95fGztUJFTWejK0K21r6OuK/FbWqE9niC7@D/7mLHuybAQFz4x5g4t0ALmcvWwyRch5tFpEfImfsr6k8BhMiGJOvnKD9aOc@NXw) **Explanation:** m->{ // Method with integer-matrix parameter and Object return-type int f=1; // Flag-integer, starting at 1 for(var a:m) // Loop over the rows of the matrix f=m[0].length!=a.length? // If the length of the first and current row aren't the same: 0 // Change `f` to 0 : // Else: f; // Leave `f` the same return m.length<1? // If there is only one row: m // Return the input-matrix as result : // Else: f>0;} // Return whether the flag `f` is still 1 as boolean