* Recursively iterates a tree node structure from parent -> children to find a match for the given element.
* The match is returned if found (null is returned if not found).
*/
private PythonpathTreeNode findMatch(TreeNode treeNode, Object element) {
if (treeNode instanceof PythonpathTreeNode) {
PythonpathTreeNode pythonpathTreeNode = (PythonpathTreeNode) treeNode;
if (element.equals(pythonpathTreeNode.file)) {
return pythonpathTreeNode;
}
}
List<TreeNode> children = treeNode.getChildren();
for (TreeNode object : children) {
PythonpathTreeNode m = findMatch(object, element);
if (m != null) {
return m;
}
}
return null;