Multiple isset block going from more specific to more generic
Long time reader, first time poster, welcoming of critique.

You could create an array populated with each variant of the property you're looking for:

    $is_set = array (
        $carData-&gt;{$owner}-&gt;{$brand}-&gt;{$part},
        $carData-&gt;{$owner}-&gt;{$brand}-&gt;allparts,
        $carData-&gt;{$owner}-&gt;allbrands-&gt;allparts,
        $carData-&gt;allowners-&gt;allbrands-&gt;allparts
    );


And then check each value in the array using a foreach loop which ends when the condition isset evaluates to true. The first property to evaluate to true is then returned which in turn breaks you out of the function (credit to Brett for the insight).

    foreach ($is_set as $this_set) {
        if isset($this_set) {
            return $this_set;
        }
    }


Putting it all together would look like:

function getCarPartColor($carData, $owner, $brand, $part) {

    $is_set = array (
        $carData-&gt;{$owner}-&gt;{$brand}-&gt;{$part},
        $carData-&gt;{$owner}-&gt;{$brand}-&gt;allparts,
        $carData-&gt;{$owner}-&gt;allbrands-&gt;allparts,
        $carData-&gt;allowners-&gt;allbrands-&gt;allparts
    );

    foreach ($is_set as $this_set) {
        if isset($this_set) {
            return $this_set;
        }
    }
}