The code in this question is from an Android application, but the question is based on Java, so I am asking it here.

Introduction:-
I wrote the following method to parse a complex SoapObject (A SoapObject is an object which has properties - each having a name and a value. Simple SoapObject would have simple name value pairs, like a String name and a String value. A complex SoapObject is the one which has SoapObjects as value of some properties, like this representation:
{String name1 => String value1,
String name2 => String value2,
String name3 => {
String name3.1 = String value3.1,
String name3.2 = String value3.2
},
String name4 => Value4}

This SoapObject contains XML data. So complex SoapObject implies that we have nested tags. I am writing the following class with a recursive method to parse this SoapObject. I have commented the code.

PROBLEM:-

I need to look for tags "title" and "summary" nested inside a tag named "entry" which is nested in a few tags. It is working fine till that, but then I need to return the data.
How it works:-
First we iterate through the SoapObject's properties.

In the iteration, we check if the current property is the last property. If yes, we check if it is SoapObject or not. If not, we check if it's name is "title" or "summary", and if true, assign its String value to the variable named "title" or "summary" as appropriate, and break the loop, after which the only statement just returns an Entry object created by passing the "title and "summary" to the Entry constructor.

if it is a SoapObject, we recursively call the function again and pass it this property SoapObject, and break from the loop.
__________________________

If the current property is not the last property, we check if it is a SoapObject or not. If not, we check if its name is "title" or "summary" and if true,assign its String value to the variable named "title" or "summary" as appropriate, and continue the loop; if it's a SoapObject, we pass it the recursive call to the function itself, and continue the loop.

Now the problem is that when I recursively call the function again, "title" and "summary" are initialized to null each time. So how can I return the data?

Java Code:
public class SearchResponseParser {
	private static final String TAG = SearchResponseParser.class.getSimpleName();
	
	/**
	 * 
	 * @author 
	 *
	 */
	public static class Entry {
		public final String title;
		public final String summary;
		
		Entry(String title, String summary) {
			this.title = title;
			this.summary= summary
		}
	}
	
	/**
	 * 
	 * @param soapObject
	 * @return
	 */
	static protected Entry parseComplexSoapObject(SoapObject soapObject) {
		String title = null;
		String summary = null;
		
		//Iterate through the properties starting at top of soapObject
		for (int i=0; i<soapObject.getPropertyCount(); i++) {

                        //Get the current property
			Object currentPropertyObject = soapObject.getProperty(i);
				
			//If current property is the last property, check if it is a string or a soap object
			if (i==soapObject.getPropertyCount()-1) {
				//If it is a string, add the key value pair of property to the map and break the loop. The only statement after the loop will return the map. 
				if(currentPropertyObject!=null && !(currentPropertyObject.getClass().equals(SoapObject.class))) {
					switch (getPropertyNameString(soapObject, i)) {
						case "title":
							title=Entry.title;
							break;
						case "summary":
							summary=Entry.summary;
							break;
					}
					//hashMap.put(getPropertyNameString(soapObject, i), getPropertyValueString(soapObject,i));
					break;
				}
				//else If it is a soap object, cast the currentPropertyObject to SoapObject and make a recursive call to the function itself, passing the current property so that the method gets "inside" this current property soap object and does all this again
				else if(currentPropertyObject!=null && currentPropertyObject.getClass().equals(SoapObject.class)) {
					SoapObject currentPropertySoapObject = (SoapObject) currentPropertyObject;
					if (getPropertyNameString(currentPropertySoapObject, i)=="entry") {
					       break;
					} else {
					       parseComplexSoapObject(currentPropertySoapObject);
					       break;
					}
				}
			}
			//else if the current property not the last property, check if it is a soap object or a string
			else {
				//if the current property is a string, add its key value pair to the string  and "continue" the loop, so that the loop continues to read the next properties
				if(currentPropertyObject!=null && !(currentPropertyObject.getClass().equals(SoapObject.class))) {
					switch (getPropertyNameString(soapObject, i)) {
						case "title":
							title=Entry.title;
							break;
						case "summary":
							summary=Entry.summary;
							break;
					}
				        //hashMap.put(getPropertyNameString(soapObject, i), getPropertyValueString(soapObject,i));
					continue;
				}
				//else if the current property is a soap object, cast the currentPropertyObject to SoapObject and make a recursive call to the function itself, passing the current property so that the method gets "inside" this current property soap object and does all this again
				else if(currentPropertyObject!=null && currentPropertyObject.getClass().equals(SoapObject.class)) {
					SoapObject currentPropertySoapObject = (SoapObject) currentPropertyObject;
					if (getPropertyNameString(currentPropertySoapObject, i)!="entry") {
					       continue;
					} else {
					       parseComplexSoapObject(currentPropertySoapObject);
					       continue; //TODO Remove it it is useless
					}
				}
			}
		}
		
		return new Entry(title, summary);
	}
	
	/**
	 * helper function to get the name of a property of a SoapObject
	 * @param soapObject
	 * @param i
	 * @return
	 */
	private static String getPropertyNameString(SoapObject soapObject, int i) {
		return getPropertyInfo(soapObject, i).getName();
	}
	
	/**
	 * helper function to get the value of a property of a SoapObject
	 * @param soapObject
	 * @param i
	 * @return
	 */
	private static String getPropertyValueString(SoapObject soapObject, int i) {
		return getPropertyInfo(soapObject, i).getValue().toString();
	}
	
	/**
	 * Helper function for above two functions
	 * @param soapObject
	 * @param i
	 * @return
	 */
	//Don't confuse this with the getPropertyInfo() method of SoapObject class.
	private static PropertyInfo getPropertyInfo(SoapObject soapObject, int i) {
		PropertyInfo propertyInfo = new PropertyInfo();
		soapObject.getPropertyInfo(i, propertyInfo);
		return propertyInfo;
	}
}